register , login model complated. plagiraism component complated(essential part of main page is complated )

This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-03-30 20:25:30 +05:00
parent 8906cf6634
commit 8b93952a06
29 changed files with 1475 additions and 205 deletions

View File

@@ -0,0 +1,40 @@
export interface RegisterErrors {
name?: string;
surname?: string;
phone?: string;
oferta?: string;
}
export function validateRegister(data: {
name: string;
surname: string;
phone: string;
oferta?: boolean;
}): RegisterErrors {
const errors: RegisterErrors = {};
if (!data.name.trim()) {
errors.name = 'Name is required';
} else if (data.name.trim().length < 2) {
errors.name = 'Name must be at least 2 characters';
}
if (!data.surname.trim()) {
errors.surname = 'Surname is required';
} else if (data.surname.trim().length < 2) {
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) {
errors.phone = 'Enter a valid 9-digit phone number';
}
if (!data.oferta) {
errors.oferta = 'You must accept the terms to continue';
}
return errors;
}