optional
This function takes a Predicate
as an argument and returns Predicate
that matches on the same conditions as the original one, but allows null
and undefined
values as well. This predicate doesn't consider missing (i.e. not existing) values as valid.
Examples:
First, let's define an example value
that we want to verify and wrap it with asVerificable():
Next, let's use the optional()
function to create Predicate
that allows optional values:
Now, let's test the new Predicate
compared to the original one:
Last updated