addRule method

Validator<String> addRule(
  1. String? rule(
    1. String?
    )
)
inherited

Adds a validation rule to the validator.

The rule should be a function that takes a value of type T? and returns a validation error message as a String?, or null if the value is valid.

Returns the current validator instance to allow method chaining.

Implementation

Validator<T> addRule(String? Function(T?) rule) {
  _rules.add(rule);
  return this;
}