minLength<T> static method

FormFieldValidator<T> minLength<T>(
  1. int minLength, {
  2. bool allowEmpty = false,
  3. String? errorText,
})

Implementation

static FormFieldValidator<T> minLength<T>(int minLength, {
  bool allowEmpty = false,
  String? errorText,
}) {
  assert(minLength > 0);
  return (T? valueCandidate) {
    assert(valueCandidate is String || valueCandidate is Iterable || valueCandidate == null);
    var valueLength = 0;
    if (valueCandidate is String) valueLength = valueCandidate.length;
    if (valueCandidate is Iterable) valueLength = valueCandidate.length;
    return valueLength < minLength && (!allowEmpty || valueLength > 0)
        ? errorText ?? BasicFormValidatorMessageError().minLength!(minLength)
        : null;
  };
}