some
Strickland provides a some
validator. The some
validator operates over an array of validators and it will exit as soon as it encounters a valid result. If any of the validators in the array are valid, then the overall result will be valid.
Parameters
The first parameter to the some
validator factory is the array of validators. Validator props can also be supplied either as an object or as a function that accepts context and returns a validator props object.
Result Properties
some
: The array of validation results produced during validation
The some
validator adds a some
property to the validation result that provides the detailed validation results of every validator that was validated in the array of validators. The validation result property is named some
to match the name of the validator (this is a common pattern in Strickland).
Usage
There are a few notable characteristics of this result:
The properties from each executed validator are added to the top-level result
The
max
validator added themax: 5
property to the resultThe
min
validator added themin: 10
property to the result
Property collisions are resolved using last-in-wins
Once validation succeeds for a validator, no further validation is performed
The
compare
validator was not executedThe props from the
compare
validator are not included on the resultThe
some
array in the result does not include an item for thecompare
validator
The top-level
isValid
prop on the result reflects the overall validation result
Last updated