Skip to content

Commit

Permalink
feat: updates profile validation (first/last name)
Browse files Browse the repository at this point in the history
- disallows entries beginning with special characters
  • Loading branch information
mohitb35 committed Nov 22, 2023
1 parent 9f30128 commit 469c4a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions public/static/locales/en/editProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"validationErrors": {
"maxChars": "Should be {{max}} characters or less",
"firstNameRequired": "First Name field is required",
"firstNameInvalid": "First name is invalid. Only these special characters are allowed: space ' . -",
"firstNameInvalid": "First name is invalid. It cannot start with a special character, and only these special characters are allowed: space ' . -",
"lastNameRequired": "Last Name field is required",
"lastNameInvalid": "Last name is invalid. Only these special characters are allowed: space ' -",
"lastNameInvalid": "Last name is invalid. It cannot start with a special character, and only these special characters are allowed: space ' -",
"emailRequired": "Email is required",
"nameRequired": "Please enter a name",
"nameInvalid": "Name is invalid. Only these special characters are allowed: space . , ' & ( ) ! -",
Expand Down
4 changes: 2 additions & 2 deletions src/features/user/CompleteSignup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export default function CompleteSignup(): ReactElement | null {
message: t('validationErrors.maxChars', { max: 50 }),
},
pattern: {
value: /^[\p{L}\p{N}\sß.'-]+$/u,
value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß.'-]*$/u,
message: t('validationErrors.firstNameInvalid'),
},
}}
Expand Down Expand Up @@ -335,7 +335,7 @@ export default function CompleteSignup(): ReactElement | null {
message: t('validationErrors.maxChars', { max: 50 }),
},
pattern: {
value: /^[\p{L}\p{N}\sß'-]+$/u,
value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß'-]*$/u,
message: t('validationErrors.lastNameInvalid'),
},
}}
Expand Down
4 changes: 2 additions & 2 deletions src/features/user/Settings/EditProfile/EditProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export default function EditProfileForm() {
message: t('validationErrors.maxChars', { max: 50 }),
},
pattern: {
value: /^[\p{L}\p{N}\sß.'-]+$/u,
value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß.'-]*$/u,
message: t('validationErrors.firstNameInvalid'),
},
}}
Expand All @@ -384,7 +384,7 @@ export default function EditProfileForm() {
message: t('validationErrors.maxChars', { max: 50 }),
},
pattern: {
value: /^[\p{L}\p{N}\sß'-]+$/u,
value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß'-]*$/u,
message: t('validationErrors.lastNameInvalid'),
},
}}
Expand Down

0 comments on commit 469c4a7

Please sign in to comment.