custom<T> static method

Validator<T> custom<T>(
  1. bool test(
    1. T value
    ),
  2. String message
)

Custom validator.

Implementation

static Validator<T> custom<T>(
  bool Function(T value) test,
  String message,
) {
  return (value) {
    if (!test(value)) {
      return ValidationResult.invalid(message);
    }
    return const ValidationResult.valid();
  };
}