all
This function takes as a parameters arbitrary number of Predicate
s, and returns a Predicate
that matches only if all of the Predicates
provided as arguments match.
If any of the Predicates
provided as arguments doesn't match the value, the error(s) returned by that first (from left hand side) failing Predicate
are returned from the combined Predicate
.
Examples:
Failing example:
First, let's define an example value
that we want to verify and wrap it with asVerificable():
Next, let's use the all()
function to combine multiple predicates into one:
Only the error(s) from the first failing Predicate
(isString
) are returned from the combinedPredicate
. Errors from the next failing predicates (isArray
) are not returned:
Matching example:
We can also create more useful combined predicate like:
And test the value against this combined Predicate
:
Last updated