requiredValidator function
Validates if a value is required.
Returns an error message if the value is null or empty, otherwise returns null.
The error message can be customized by providing a message parameter.
If no message is provided, it will use the default message based on the current localization.
Example usage:
String? errorMessage = requiredValidator(value);
if (errorMessage != null) {
print(errorMessage);
}
Implementation
String? requiredValidator(String? value, [String? message]) =>
(value == null || value.isEmpty)
? (message ??
(getCurrentLocalization() == 'id'
? 'Kolom tidak boleh kosong'
: "Field can't be empty"))
: null;