postalAddressValidator static method
postalAddressValidator to validate postal address
validator: (value) => SimpleValidations.postalAddressValidator(value, [errorMessage]),
Implementation
static String? postalAddressValidator(String? value, [String? errorMessage]) {
RegExp regex = CustomRegEx.postalAddressRegex;
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
} else if (!regex.hasMatch(value)) {
return errorMessage ?? 'Please enter a valid postal address';
}
return null;
}