Value validator from array of items #20280
Replies: 2 comments
-
It doesn't seems we have much info about property except the value: ![]() ![]() It seems it is called here: @AndyButland @Zeegaan it is possible we can pass in Of course it can just be called "items" all the time, but what if one has two "items" (items 1 and 2) property in a more complex configuration or want to use same validator for two configuration properties in two different property editor (but we don't want to re-invent the wheel). |
Beta Was this translation helpful? Give feedback.
-
We had a chat about this internally, and we feel that validators should be self-contained. That being said, it makes sense to build for reuse. Perhaps this could be solved by introducing an abstract base class for the ValueListUniqueValueValidator which lets the concrete implementation provide a field name for the validation? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently we have a validator here, which is used for an array of items (string array) like dropdown, radiobutton and checkbox lists:
https://github.com/umbraco/Umbraco-CMS/blob/fc60b5b5ffa1db5f9f1ee786f65ad33c9f44f4e3/src/Umbraco.Infrastructure/PropertyEditors/ValueListUniqueValueValidator.cs
A few issues:
When validating it assumes property is named
items
although it probably works anyway as object value is passed in, but can it handle the name correct here?Umbraco-CMS/src/Umbraco.Infrastructure/PropertyEditors/ValueListUniqueValueValidator.cs
Lines 41 to 58 in fc60b5b
Color Picker used a custom one, which is probably fine as it does some special regex for hex value, but it would be great it handle
items
as well if one re-use this in a configuration of a custom property editor:Umbraco-CMS/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs
Lines 47 to 59 in fc60b5b
Assuming we sometime later support value/label for dropdown etc. it will be useful if
ValueListUniqueValueValidator
can handlevalue
in array of objects - or perhaps a different validator.Configurate text and value for prevalues in dropdown #11084
Beta Was this translation helpful? Give feedback.
All reactions