aadhaarValidator static method
aadhaarValidator to validate Aadhaar card number
validator: (value) => SimpleValidations.aadhaarValidator(value, [errorMessage]),
Implementation
static String? aadhaarValidator(String? value, [String? errorMessage]) {
RegExp regex = CustomRegEx.aadhaarRegex;
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
} else if (value.length != 12) {
return errorMessage ?? 'Please enter a valid Aadhaar number';
} else if (!regex.hasMatch(value)) {
return errorMessage ?? 'Please enter a valid Aadhaar number';
}
return null;
}