ValidatorUtils<S, T> extension
Utilities that can be called on a Validator
Scope for all instance methods
- on
-
- ValidatorT<
S, T>
- ValidatorT<
Methods
-
catching(
[Selector< Exception, ValidationError> ? handler]) → ValidatorT<S, T> - Creates a new validator from the caller that will catch an errors when evaluating the validating function.
-
errors<
ErrorType> (S subject) → List< ErrorType> - Runs the validator and returns a list of errors
-
firstError<
ErrorType> (S subject) → ErrorType? - Runs the validator and returns the first error of the provided generic type
-
flatMap<
O> (ValidatorT< T, O> process(T)) → ValidatorT<S, O> - Recieves a function that generates a validator and plumbs the output of the current to validator to the function.
-
join<
O> (ValidatorT< T, O> validator) → ValidatorT<S, O> - Chains a validation to the output
-
map<
O> (Function1< T, O> transform) → ValidatorT<S, O> - Transforms the ouput of the validator by running the provided function. Leaving the validation logic untouched. returns validator with coerced output.
-
mapErrors<
E> (Function1< dynamic, E?> transform) → ValidatorT<S, T> - Transforms errors produced by the validor Leaving the validation logic untouched. returns validator with coerced output.
-
then<
O> (ValidatorT< T, O> validator) → ValidatorT<S, O> - Chains a validation to the output
-
validated(
S subject) → T? - Returns the validated and transformed subject If validation of subject fails returns null
-
verify<
ErrorType extends ValidationError> (S subject) → Either< List< ErrorType> , T> - Runs the validator on the supplied subject.