From 6a27623fc0cf31e8229a8d64e1505d1065d8148a Mon Sep 17 00:00:00 2001 From: Mahendra Date: Wed, 15 Jan 2025 15:55:59 +0530 Subject: [PATCH] fix: sign up error in first anme [] --- src/lib/utils/validation.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/validation.ts b/src/lib/utils/validation.ts index 83e775f..392ab28 100644 --- a/src/lib/utils/validation.ts +++ b/src/lib/utils/validation.ts @@ -2,6 +2,8 @@ import * as yup from 'yup'; const emailRegex = /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]+)$/; const firstNameRegex = /^[A-Za-z\s]+$/; const lastNameRegex = /^[A-Za-z\s]*$/; +const firstNameSpaceCheck = /^[^\s].*$/; + //----------------------------- Check Validation ---------------------// export const checkValidation = async (validationSchema, val) => { @@ -25,7 +27,11 @@ export const registrationSchema = yup.object().shape({ .email() .matches(emailRegex, 'Please enter a valid Email ID') .required('Please enter a valid Email ID'), - firstName: yup.string().trim().matches(firstNameRegex, "Your first name cannot have numbers or special characters.").required('Please enter your first name.'), + firstName:yup + .string() + .matches(firstNameRegex, "Your first name cannot have numbers or special characters.") + .matches(firstNameSpaceCheck , 'Your first name cannot start with spaces.') + .required('Please enter your first name.'), lastName: yup.string().matches(lastNameRegex, "Your last name cannot have numbers or special characters."), password: yup .string()