fix mask formatter in phone

This commit is contained in:
mso7nueh
2026-01-29 15:49:13 +03:00
parent 4ff880e079
commit 044d86e710
4 changed files with 27 additions and 5 deletions

View File

@@ -16,6 +16,21 @@ class ValidationUtils {
return regex.hasMatch(phone);
}
/// Нормализация номера телефона (+79991234455)
static String normalizePhone(String phone) {
if (phone.isEmpty) return '';
final digits = phone.replaceAll(RegExp(r'[^\d]'), '');
if (digits.isEmpty) return '';
String normalized = digits;
if (digits.startsWith('8')) {
normalized = '7${digits.substring(1)}';
} else if (digits.length == 10) {
normalized = '7$digits';
}
return '+$normalized';
}
/// Валидация URL
static bool isValidUrl(String url) {
if (url.isEmpty) return false;