minimalLengthValidator function
Validates if the given value meets the minimum length requirement.
Returns an error message if the value is null or empty, or if its length is less than length.
The error message is based on the current localization, either in Indonesian or English.
If the value is valid, returns null.
Implementation
String? minimalLengthValidator(String? value, int length) {
if (value == null || value.isEmpty) {
return getCurrentLocalization() == 'id'
? 'Kolom tidak boleh kosong'
: "Field can't be empty";
} else if (value.length < length) {
return getCurrentLocalization() == 'id'
? 'Masukan minimal $length karakter'
: 'Please fill in at least $length characters';
}
return null;
}