In general + for #1743686: Condition Plugin System we'll need choice based validation, i.e. validate whether the value is one of the allowed ones. Symfony has a constraint for that. In my test it triggered a deprecated warning, what I think is a symfony bug though.
Also, for validating multiple-valued typed data objects (=lists) we'll need to fix our current validator integration as right now lists are not un-wrapped and the constraint validator dies when receiving the array-access object containing typed objects. To solve that I'd suggest adding an isComplexData() helper function to typed data and make it return TRUE for lists containing complex data and FALSE for lists containing simple data. Then we unwrap simple data only and have validation work.
Related:
#1913328: Provide general list and map classes
#1758622: Provide the options list of an entity field - once we've done that we can leverage it for validation.
Comment | File | Size | Author |
---|---|---|---|
#3 | d8_choice.patch | 2.38 KB | fago |
Comments
Comment #1
fagoAlso tagging as typed-data.
Comment #2
fagoHere is my start - without the typed data fixes or fixing the choice validator using a deprecated method.
Usage would be like that:
Once we've typed data options-list as callback we might want to default to this one.
Comment #3
fagoForgot to post interim work.
Comment #3.0
fagoUpdated issue summary.
Comment #4
fagoMeanwhile we've allowed values validation based on typed data already.