Integrate themed login/signup, EN/RU localization, shared dummy providers, verification recovery screens and named URL routes. Store frontend guidelines, workflow skills, validation and delivery documentation. Related to #2, #3, #5 and #6.
36 lines
970 B
Dart
36 lines
970 B
Dart
import '../generated/i18n/app_localizations.dart';
|
|
|
|
abstract final class AuthValidation {
|
|
static String? email(String? value, AppLocalizations l) {
|
|
final email = value?.trim() ?? '';
|
|
if (email.isEmpty) return l.emailRequired;
|
|
if (!RegExp(r'^[^\s@]+@[^\s@]+\.[^\s@]+$').hasMatch(email)) {
|
|
return l.emailInvalid;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static String? name(String? value, AppLocalizations l) =>
|
|
(value?.trim().isEmpty ?? true) ? l.nameRequired : null;
|
|
|
|
static String? password(
|
|
String? value,
|
|
AppLocalizations l, {
|
|
required bool signUp,
|
|
}) {
|
|
if (value == null || value.isEmpty) return l.passwordRequired;
|
|
if (signUp && value.length < 12) return l.passwordHint;
|
|
return null;
|
|
}
|
|
|
|
static String? confirmation(
|
|
String? value,
|
|
String password,
|
|
AppLocalizations l,
|
|
) => value == null || value.isEmpty
|
|
? l.confirmationRequired
|
|
: value != password
|
|
? l.passwordMismatch
|
|
: null;
|
|
}
|