The Predicate() constructor creates Predicate objects.
Syntax
Parameters
predicateFunction A function which returns a Boolean value or a Promise that fulfills with a Boolean value.
Return value
A new Predicate instance.
Exceptions
If neither a function nor another Predicate is passed as the only parameter throws the corresponding error.
Description
Creates a new Predicate instance. It is just a container for a predicate function which will be unpacked in the Validation().constraint() method. The main purpose of it is attaching state callbacks to a predicate function before passing it into the Validation().constraint() method. If another Predicate is passed as the only parameter, a new (cloned) instance will be returned with the predicate function and state callbacks of the passed Predicate.
Examples
Passing a predicate function with state callbacks
Cloning a Predicate
In this example there are two Predicates which have the same predicate function and valid and invalid state callbacks. But the second one additinaly have started and validated state callbacks added. In other words the second one has everything what the first one has plus two more state callbacks. So we clone the first one and add two extra state callbacks. It spares us from writing a pair of lines of code, but there could be much more.