minMaxLength static method

FormFieldValidator<String> minMaxLength(
  1. int minLength,
  2. int maxLength, [
  3. String? message
])

Implementation

static FormFieldValidator<String> minMaxLength(int minLength, int maxLength, [String? message]) {
  return (String? value) {
    if ((value?.length ?? 0) < minLength || (value?.length ?? 0) > maxLength) {
      return message ?? 'This field must be between $minLength and $maxLength characters';
    }

    return null;
  };
}