From 45c1f3ba1865ba559dffda9ca30d97c54e586133 Mon Sep 17 00:00:00 2001 From: borislavstoychev Date: Thu, 4 Aug 2022 12:07:08 +0300 Subject: [PATCH 1/2] first name and last name validation --- src/components/auth/register/RegisterForm.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/components/auth/register/RegisterForm.tsx b/src/components/auth/register/RegisterForm.tsx index 6f8f24a31..8eff75f2f 100644 --- a/src/components/auth/register/RegisterForm.tsx +++ b/src/components/auth/register/RegisterForm.tsx @@ -12,7 +12,7 @@ import GenericForm from 'components/common/form/GenericForm' import SubmitButton from 'components/common/form/SubmitButton' import FormTextField from 'components/common/form/FormTextField' import PasswordField from 'components/common/form/PasswordField' -import { email, password } from 'common/form/validation' +import { email, password, name } from 'common/form/validation' export type RegisterFormData = { firstName: string @@ -21,15 +21,12 @@ export type RegisterFormData = { password: string } -const validationSchema: yup.SchemaOf = yup - .object() - .defined() - .shape({ - firstName: yup.string().min(3).max(100).required(), - lastName: yup.string().min(3).max(100).required(), - email: email.required(), - password: password.required(), - }) +const validationSchema: yup.SchemaOf = yup.object().defined().shape({ + firstName: name.required(), + lastName: name.required(), + email: email.required(), + password: password.required(), +}) const defaults: RegisterFormData = { firstName: '', From 2413a04824910e80ed48f513eeace27ee1cb8ed3 Mon Sep 17 00:00:00 2001 From: borislavstoychev Date: Thu, 4 Aug 2022 12:26:18 +0300 Subject: [PATCH 2/2] included confirm password field and translation --- public/locales/bg/auth.json | 2 +- public/locales/en/auth.json | 11 +++++++++++ src/components/auth/register/RegisterForm.tsx | 19 +++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/public/locales/bg/auth.json b/public/locales/bg/auth.json index 58ba88cd5..b75ffd2b3 100644 --- a/public/locales/bg/auth.json +++ b/public/locales/bg/auth.json @@ -29,7 +29,7 @@ "account": { "email": "Email", "new-password": "Нова парола", - "confirm-password": "Потвърди нова парола", + "confirm-password": "Потвърди парола", "previous-password": "Стара парола", "first-name": "Име", "last-name": "Фамилия", diff --git a/public/locales/en/auth.json b/public/locales/en/auth.json index b6a19f6cf..da6ca75d2 100644 --- a/public/locales/en/auth.json +++ b/public/locales/en/auth.json @@ -25,5 +25,16 @@ "forgotten-password": { "instructions": "To reset your password, please type your email address below. We will then send you an email with instructions to follow." } + }, + "account": { + "email": "Email", + "new-password": "New password", + "confirm-password": "Confirm password", + "previous-password": "Previous password", + "first-name": "First name", + "last-name": "Last name", + "phone": "Phone", + "company": "Company", + "message": "Message" } } diff --git a/src/components/auth/register/RegisterForm.tsx b/src/components/auth/register/RegisterForm.tsx index 8eff75f2f..3de8a6daa 100644 --- a/src/components/auth/register/RegisterForm.tsx +++ b/src/components/auth/register/RegisterForm.tsx @@ -21,12 +21,16 @@ export type RegisterFormData = { password: string } -const validationSchema: yup.SchemaOf = yup.object().defined().shape({ - firstName: name.required(), - lastName: name.required(), - email: email.required(), - password: password.required(), -}) +const validationSchema: yup.SchemaOf = yup + .object() + .defined() + .shape({ + firstName: name.required(), + lastName: name.required(), + email: email.required(), + password: password.required(), + 'confirm-password': yup.string().oneOf([yup.ref('password')], 'validation:password-match'), + }) const defaults: RegisterFormData = { firstName: '', @@ -97,6 +101,9 @@ export default function RegisterForm({ initialValues = defaults }: RegisterFormP + + +