validate static method

String? validate(
  1. String? value,
  2. List<ValidationRule> rules
)

Validates the value against a list of rules.

Returns the first error message found, or null if all rules pass.

Implementation

static String? validate(String? value, List<ValidationRule> rules) {
  for (final rule in rules) {
    final error = rule(value);
    if (error != null) return error;
  }
  return null;
}