email static method

String? email(
  1. String? string
)

Check if the string is an email if string is not null and not empty.

Returns null if is valid.

Returns FieldBlocValidatorsErrors.email if is not valid.

Implementation

static String? email(String? string) {
  final emailRegExp =
      RegExp(r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$');
  if (string == null || string.isEmpty || emailRegExp.hasMatch(string)) {
    return null;
  }

  return FieldBlocValidatorsErrors.email;
}