Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to use special characters for First Name and Last Name #2902

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/app-text-field/AppTextField.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const styles = {
helperText: (multiline?: boolean) => ({
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
whiteSpace: 'pre-wrap',
mr: multiline ? '48px' : '14px'
})
}
2 changes: 1 addition & 1 deletion src/constants/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"emptyField": "This field cannot be empty",
"hasOnlySpaces": "This field must contain at least one non-space character",
"nameLength": "This field cannot be longer than 30 characters",
"nameAlphabeticOnly": "This field can contain alphabetic characters only",
"nameCharacters": "This field can contain alphabetic characters, spaces, apostrophes, or hyphens",
"passwordsDontMatch": "Passwords do not match",
"samePasswords": "New password cannot be the same as the current one",
"currentPassword": "Enter your current password",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/translations/uk/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"emptyField": "Це поле не може бути порожнім",
"hasOnlySpaces": "Поле повинно містити принанні один символ, який не є пробілом",
"nameLength": "Довжина цього поля не може перевищувати 30 символів",
"nameAlphabeticOnly": "Це поле може містити лише букви",
"nameCharacters": "Це поле може містити лише літери, пробіли, апострофи та дефіси",
"passwordsDontMatch": "Паролі не збігаються",
"samePasswords": "Новий пароль не повинен бути таким самим, як попередній",
"currentPassword": "Введіть попередній пароль",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validations/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const validations: Validations = {
return 'common.errorMessages.nameLength'
}
if (!validationPatterns.name.test(value)) {
return 'common.errorMessages.nameAlphabeticOnly'
return 'common.errorMessages.nameCharacters'
}
return ''
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validations/validations.constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const validationPatterns = {
name: /^[a-zа-яєії]+$/i,
name: /^[a-zа-яєії' -]+$/i,
number: /^-?(?:\d+|\d*\.\d+)(?:[eE][+-]?\d+)?$/,
email: /^([a-z\d]+([._-][a-z\d]+)*)@([a-z\d]+([.-][a-z\d]+)*\.[a-z]{2,})$/i,
passwordValid: /^\S+$/i,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/common.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const mockedValues = {
}

const errorMessages = {
nameAlphabeticOnly: 'common.errorMessages.nameAlphabeticOnly',
nameCharacters: 'common.errorMessages.nameCharacters',
nameLength: 'common.errorMessages.nameLength',
numbersOnly: 'common.errorMessages.numbersOnly',
positiveNumbersOnly: 'common.errorMessages.positiveNumbersOnly',
Expand All @@ -49,7 +49,7 @@ export const passwordField = (value) => {
describe('commonValidation', () => {
it('Should return error that only alphabetical characters are allowed', () => {
const result = nameField(mockedValues.nameWithNumbers)
expect(result).toBe(errorMessages.nameAlphabeticOnly)
expect(result).toBe(errorMessages.nameCharacters)
})

it('Should return error that name is too long', () => {
Expand Down