Currently a validator needs to be added to fields with a children attribute to make the constraints object valid. This enables the flexibility of using validateIsNonEmpty or a custom validator that checks for a minimum or maximum number of values, however it would be nice to provide a default of validateIsArray if the validator is missing.
This will involve two steps:
Validation
This will mean amending the constraints validation to allow an object to pass if the following conditions are met:
it has a children field
Currently the validation is of whitelisted keys which will fail if no validator field is present.
A more specialised validator is needed, that checks the other fields for a children field if no validator field is present.
Defaults
The default value of 'validatorwill need to be set to 'validateIsArray. This is a little clunky, but will work short-term. Longer term, the application of defaultValue should probably work with functions that can decide on a default value based on the object as a whole.
Currently a validator needs to be added to fields with a
children
attribute to make the constraints object valid. This enables the flexibility of usingvalidateIsNonEmpty
or a custom validator that checks for a minimum or maximum number of values, however it would be nice to provide a default ofvalidateIsArray
if the validator is missing.This will involve two steps:
This will mean amending the constraints validation to allow an object to pass if the following conditions are met:
children
fieldCurrently the validation is of whitelisted keys which will fail if no
validator
field is present.A more specialised validator is needed, that checks the other fields for a
children
field if novalidator
field is present.The default value of 'validator
will need to be set to 'validateIsArray
. This is a little clunky, but will work short-term. Longer term, the application of defaultValue should probably work with functions that can decide on a default value based on the object as a whole.