login register comlated

This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-04-01 18:26:25 +05:00
parent 9414ce0c8a
commit 7b76901f5f
23 changed files with 576 additions and 102 deletions

View File

@@ -3,6 +3,7 @@ export interface RegisterErrors {
surname?: string;
phone?: string;
oferta?: string;
password?: string;
}
export function validateRegister(data: {
@@ -10,6 +11,7 @@ export function validateRegister(data: {
surname: string;
phone: string;
oferta?: boolean;
password: string;
}): RegisterErrors {
const errors: RegisterErrors = {};
@@ -25,11 +27,15 @@ export function validateRegister(data: {
errors.surname = 'Surname must be at least 2 characters';
}
const digits = data.phone.replace(/\D/g, '');
if (!digits) {
errors.phone = 'Phone is required';
} else if (digits.length !== 9 && digits.length !== 12) {
errors.phone = 'Enter a valid 9-digit or 13-digit phone number';
if (!data.phone || data.phone.length < 12) {
// "998" prefix (3) + 9 digits = 12
errors.phone = 'Enter a valid 9-digit phone number';
}
if (!data.password) {
errors.password = 'Password is required';
} else if (data.password.length < 6) {
errors.password = 'Password must be at least 6 characters';
}
if (!data.oferta) {