V15: Add MNTP serverside validation#18526
Conversation
# Conflicts: # src/Umbraco.Core/EmbeddedResources/Lang/da.xml # src/Umbraco.Core/EmbeddedResources/Lang/en.xml # src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml
AndyButland
left a comment
There was a problem hiding this comment.
Looks good to me. I made a few updates but only minor things to resolve a few code warnings.
I did some manual testing on this via manipulating requests to the API, and that verified the functionality, on top of the tests you already had.
I found one issue though - but might be one to look at in a separate PR as I don't suspect it's particularly related to the MNTP, but could be anything that takes an array as a value.
If you post an empty array for the value, e.g.:
{
"template":null,
"values":[
{
"editorAlias":"Umbraco.MultiNodeTreePicker",
"alias":"pickedContent",
"culture":null,
"segment":null,
"value":[
]
}
],
"variants":[
...
],
"cultures":[
]
}
When you inspect the ValidateUpdateDocumentRequestModel requestModel parameter passed in ValidateUpdateDocumentController, you'll see the value is null not an empty array. And because of that, none of the validation runs. This means if you set a minimum value, but provide no items, it won't get flagged as invalid.
I'll approve - but up to you if you want to look at that as part of this PR, or merge this and tackle it separately.
Might be related to: dotnet/aspnetcore#37630
# Conflicts: # src/Umbraco.Core/EmbeddedResources/Lang/en.xml # src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml # src/Umbraco.Infrastructure/PropertyEditors/MediaPicker3PropertyEditor.cs
|
Good catch, thanks Andy, I've fixed it and amended the tests, turns out it was also a mistake in the And thanks for the fixes 👍 |
Adds serverside validation for the multinode tree picker.
Adds amount and object type validation.
Dynamic root validation is skipped for now, since the validator has no concept of where it is in the tree, this means that the dynamic root query cannot be resolved.
For testing see #18429 but tests should cover it.