throwInstead function
- IValidator validator
Returns a Validator that throws a ValidatorFailedException instead of returning a result
Implementation
IValidator throwInstead(IValidator validator) => Validator<Result>((value) {
final resOr = validator.validator(value);
if (resOr is Future<Result>) return _throwInsteadAsync(resOr);
if (resOr.isNotValid) throw ValidatorFailedException(resOr);
return Result.valid(value);
});