validate static method
Validates that the input is a valid Thai ID Card Number.
errorText: The error message to display if invalid. Default is 'Invalid Thai ID Card Number'.
allowEmpty: If true, empty input is considered valid (useful for optional fields). Default is false.
Implementation
static FormFieldValidator<String> validate({
String errorText = 'Invalid Thai ID Card Number',
bool allowEmpty = false,
}) {
return (String? value) {
if (value == null || value.isEmpty) {
return allowEmpty ? null : errorText;
}
// Normalize and validate
final isValid = ThaiIdCardNumbers().validateFormatted(value);
return isValid ? null : errorText;
};
}