This commit is contained in:
Mohammed Al-Samarraie
2026-01-13 12:43:43 +03:00
parent 4df24f5d8d
commit ac8a769ff0
23 changed files with 945 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
class Validators {
static String? validateEmail(String? value) {
if (value == null || value.isEmpty) {
return 'البريد الإلكتروني مطلوب';
}
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegex.hasMatch(value)) {
return 'البريد الإلكتروني غير صحيح';
}
return null;
}
static String? validatePhone(String? value) {
if (value == null || value.isEmpty) {
return 'رقم الهاتف مطلوب';
}
// Add your phone validation logic here
return null;
}
static String? validateRequired(String? value, String fieldName) {
if (value == null || value.isEmpty) {
return '$fieldName مطلوب';
}
return null;
}
static String? validatePassword(String? value) {
if (value == null || value.isEmpty) {
return 'كلمة المرور مطلوبة';
}
if (value.length < 6) {
return 'كلمة المرور يجب أن تكون 6 أحرف على الأقل';
}
return null;
}
}