Shuffle/app/lib/features/auth/domain/validation/email_format.dart
cschlaefke 54337ffc59 feat(auth): add auth domain, repository, validators and router redirects
Refs #1

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 00:09:47 +01:00

23 lines
663 B
Dart

/// Fehler der E-Mail-Adresse.
enum EmailError { empty, invalid }
/// Einfache Syntaxprüfung (Feinprüfung macht der Server): ein `@`, Text davor,
/// ein Punkt im Domänenteil, kein Leerraum.
abstract final class EmailFormat {
static const maxLength = 254;
static final _pattern = RegExp(r'^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$');
static String normalize(String value) => value.trim();
static EmailError? validate(String value) {
final email = normalize(value);
if (email.isEmpty) {
return EmailError.empty;
}
if (email.length > maxLength || !_pattern.hasMatch(email)) {
return EmailError.invalid;
}
return null;
}
}