/// Form validators for authentication class AuthValidators { AuthValidators._(); /// Validates email format static String? validateEmail(String? value) { if (value == null || value.isEmpty) { return 'Email is required'; } final emailRegex = RegExp( r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', ); if (!emailRegex.hasMatch(value)) { return 'Please enter a valid email address'; } return null; } /// Validates password strength /// Requirements: min 8 characters, at least one uppercase, one lowercase, one number static String? validatePassword(String? value) { if (value == null || value.isEmpty) { return 'Password is required'; } if (value.length < 8) { return 'Password must be at least 8 characters'; } if (!RegExp(r'[A-Z]').hasMatch(value)) { return 'Password must contain at least one uppercase letter'; } if (!RegExp(r'[a-z]').hasMatch(value)) { return 'Password must contain at least one lowercase letter'; } if (!RegExp(r'[0-9]').hasMatch(value)) { return 'Password must contain at least one number'; } return null; } /// Validates name field static String? validateName(String? value) { if (value == null || value.isEmpty) { return 'Name is required'; } if (value.length < 2) { return 'Name must be at least 2 characters'; } if (value.length > 50) { return 'Name must not exceed 50 characters'; } return null; } /// Validates password confirmation static String? validateConfirmPassword(String? value, String password) { if (value == null || value.isEmpty) { return 'Please confirm your password'; } if (value != password) { return 'Passwords do not match'; } return null; } /// Simple password validator for login (no strength requirements) static String? validateLoginPassword(String? value) { if (value == null || value.isEmpty) { return 'Password is required'; } return null; } }