ageValidator static method
ageValidator to validate age
validator: (value) => SimpleValidations.ageValidator(value, [errorMessage]),
Implementation
static String? ageValidator(int? value, [String? errorMessage]) {
if (value == null) {
return errorMessage ?? 'Required';
} else if (value <= 0 || value > 150) {
return errorMessage ?? 'Please enter a valid age';
}
return null;
}