latitudeValidator static method

String? latitudeValidator(
  1. String? value, [
  2. String? errorMessage
])

latitudeValidator to validate if the provided value matches the pattern of a valid latitude coordinate, ranging from -90 to +90 degrees

validator: (value) => SimpleValidations.latitudeValidator(value, [errorMessage]),

Implementation

static String? latitudeValidator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.latitudeRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid latitude';
  }
  return null;
}