Predicates

Predicates are functions defining validation rules in verifica. Examples are: isString, isNumberInRange, etc.

❓ What are predicates?

Predicates are functions, that define if a value represented by Verificable object matches certain condition. They are then passed into validation methods (i.e. ensure(), getErrors(), isValid()) where the Verificable is checked for matching the Predicate.

Predicate functions can (and should!) be written by you to define your specific validation needs.

There is also a number of Predicate functions built in the library (e.g. isString, isObject, etc.) that can be used to validate simple values, or used within your own custom Predicate functions as building blocks for more complex rules.

Last updated