validate method
Validates the control
.
Implementation
@override
Map<String, dynamic>? validate(AbstractControl<dynamic> control) {
// don't validate empty values to allow optional controls
if (control.value == null) {
return null;
}
List<dynamic>? collection;
if (control is FormArray<dynamic>) {
collection = control.value;
} else if (control is FormGroup) {
collection = control.value.keys.toList();
} else if (control is FormControl<Iterable<dynamic>>) {
collection = control.value?.toList();
} else if (control is FormControl<String> || control.value is String) {
collection = control.value.toString().runes.toList();
}
return (collection != null && collection.length >= minLength)
? null
: <String, dynamic>{
ValidationMessage.minLength: {
'requiredLength': minLength,
'actualLength': collection != null ? collection.length : 0,
}
};
}