email static method

String? email(
  1. String? value, [
  2. String? message
])

Email validation

Implementation

static String? email(String? value, [String? message]) {
  if (value == null || value.isEmpty) return null;
  final regex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
  if (!regex.hasMatch(value)) {
    return message ?? 'Please enter a valid email address';
  }
  return null;
}