throwInstead function

Validator throwInstead(
  1. Validator validator
)

Returns a Validator that throws a ValidatorFailedException instead of returning a result

Implementation

Validator throwInstead(Validator validator) {
  return (value) {
    final result = validator(value);
    if (result.isNotValid) throw ValidatorFailedException(result);

    return Result.valid;
  };
}