abstract class EmailValidator {
  static String? validate(String? email, {bool isRequired = true}) {
    // Regular expression for validating emails
    final RegExp phoneRegExp = RegExp(
      r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
    );

    if (isRequired && (email == null || email.isEmpty)) {
      return 'Email is required';
    } else if (email != null && !phoneRegExp.hasMatch(email)) {
      return 'Invalid email';
    }
    return null;
  }
}
