validators/combinator library
Combinator Validators
This file contains validators for combining multiple validation rules.
Functions
-
all(
List< IValidator> validators) → IValidator - Passes the test if all of the Validators are valid, and fails if any of them are invalid
-
any(
List< IValidator> validators) → IValidator - Passes the test if any of the Validators are valid, and fails if any are invalid
-
none(
List< IValidator> validators) → IValidator - Passes the test if none of the validators pass
-
not(
IValidator validator) → IValidator - Passes the test if the passed in validator is not valid
-
throwInstead(
IValidator validator) → IValidator - Returns a Validator that throws a ValidatorFailedException instead of returning a result
-
when(
IValidator condition, {required IValidator then, required IValidator otherwise}) → IValidator - Creates a conditional validator. It's conditional based on some other field in the eskema.
-
withExpectation(
IValidator child, Expectation error) → IValidator -
Returns a IValidator that wraps the given
child
validator and adds the providederror
message to the result if the validation fails. Preserves the underlying child'scode
anddata
(if the child failed). See docs/expectation_codes.md.