getErrors
This function assesses if the provided verificable
matches or not the provided predicate
.
Returns empty array if predicate
is matched, otherwise returns array of VerificaError
objects.
Examples:
First, let's define an example object user
that we want to verify and wrap it with asVerificable():
If verificable
matches specified Predicate
, function getErrors()
returns empty array indicating there were no errors.
We can use Verificable
object properties that allow us to access any arbitrary path on the object, no matter how deeply nested, and the value of it will be Validatable
object as well, representing possible value at the same path on the original object.
This allows us to easily verify nested properties:
If value represented by provided Verificable
object doesn't match the Predicate
, function getErrors()
will return an array of ValidationError
objects describing the underlying error:
The guaranteed fields on a VerificableError
object are type
being a string defining the error type, and a path
property describing what possible nested path value failed the validation.
Last updated
Was this helpful?