phone static method

String? phone(
  1. String? string, {
  2. String? errorMessage,
})

Phone number validator (basic).

Implementation

static String? phone(String? string, {String? errorMessage}) {
  final phoneRegExp = RegExp(r'^\+?[0-9]{7,15}$');
  if (string == null || string.isEmpty || phoneRegExp.hasMatch(string)) {
    return null;
  }
  return errorMessage ?? FieldBlocValidatorsErrors.phone;
}