next A function to invoke in case the error is not needed to be catched and instead is needed to be passed further.
Return value
The Predicate object.
Exceptions
If anything other than a function is passed in the corresponding error will be thrown.
Description
Adds error state callbacks to the Predicate object. Once the Predicate is in the error state, the callbacks will be invoked one by one in the order they were added. The main purpose of error state callbacks is to perform side effects related to the error state.
This method catches errors that occur in predicate functions and in their associated state callbacks when the Validation.validate() method gets invoked (or the Validation object is used as an event handler or middleware).
If you want to just perform side effects and not to catch the error on this level, it is possible to forward the error further to catch it on the Validation().error() level by calling the function passed into a callback as the parameter next. If you add several error state callbacks in a row, calling the function next in only one of them is enough.