login register comlated
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user