not function
- IValidator validator
Passes the test if the passed in validator is not valid
When the inner validator succeeds, the failure will reuse its code
if present,
otherwise falls back to logic.not_expected
. See docs/expectation_codes.md.
Implementation
IValidator not(IValidator validator) => Validator<Result>((value) {
final resOr = validator.validator(value);
if (resOr is Future<Result>) return _notAsync(value, resOr);
return Result(
isValid: !resOr.isValid,
expectations: resOr.expectations
.map((error) => error.copyWith(
message: 'not ${error.message}', code: error.code ?? 'logic.not_expected'))
.toList(),
value: value,
);
});