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