all
$all
A constraint that checks whether all the provided processors return a defined value.
Returns the last defined value returned from the processors, or throws if any returned undefined or threw an error. Be careful to not use this in a situation where the provided processors may require late-resolved values! This works best in finalizers, validators, or in opaque schema transformers.
See $and if you want to check for truthiness instead of defined values.
Parameters
processors(Array<ProcessorSpec>, required): Array of processor specifications, all of which must return a defined value.
Example
// Validate that all normalizations succeed for a value that must satisfy multiple constraints
new Schema('string').validator({
$all: ['$non-empty', '$email', {$matches: /\.com$/}]
})
// Ensure a value passes both a type check and a range constraint
new Schema('any').validator({$all: ['$numeric', {$range: {min: 0, max: 100}}]})