diff --git a/src/components/app-text-field/AppTextField.styles.ts b/src/components/app-text-field/AppTextField.styles.ts index 258e66237..c5e91e141 100644 --- a/src/components/app-text-field/AppTextField.styles.ts +++ b/src/components/app-text-field/AppTextField.styles.ts @@ -2,7 +2,7 @@ export const styles = { helperText: (multiline?: boolean) => ({ overflow: 'hidden', textOverflow: 'ellipsis', - whiteSpace: 'nowrap', + whiteSpace: 'pre-wrap', mr: multiline ? '48px' : '14px' }) } diff --git a/src/constants/translations/en/common.json b/src/constants/translations/en/common.json index f8c1db427..276caecdd 100644 --- a/src/constants/translations/en/common.json +++ b/src/constants/translations/en/common.json @@ -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", diff --git a/src/constants/translations/uk/common.json b/src/constants/translations/uk/common.json index 9a58e0351..58d785a11 100644 --- a/src/constants/translations/uk/common.json +++ b/src/constants/translations/uk/common.json @@ -81,7 +81,7 @@ "emptyField": "Це поле не може бути порожнім", "hasOnlySpaces": "Поле повинно містити принанні один символ, який не є пробілом", "nameLength": "Довжина цього поля не може перевищувати 30 символів", - "nameAlphabeticOnly": "Це поле може містити лише букви", + "nameCharacters": "Це поле може містити лише літери, пробіли, апострофи та дефіси", "passwordsDontMatch": "Паролі не збігаються", "samePasswords": "Новий пароль не повинен бути таким самим, як попередній", "currentPassword": "Введіть попередній пароль", diff --git a/src/utils/validations/common.ts b/src/utils/validations/common.ts index 90f67d6b0..a8e86d91c 100644 --- a/src/utils/validations/common.ts +++ b/src/utils/validations/common.ts @@ -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 '' }, diff --git a/src/utils/validations/validations.constants.ts b/src/utils/validations/validations.constants.ts index cf64ac222..a01a021ae 100644 --- a/src/utils/validations/validations.constants.ts +++ b/src/utils/validations/validations.constants.ts @@ -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, diff --git a/tests/unit/utils/common.spec.jsx b/tests/unit/utils/common.spec.jsx index 5b3df6c33..fcf2c8566 100644 --- a/tests/unit/utils/common.spec.jsx +++ b/tests/unit/utils/common.spec.jsx @@ -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', @@ -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', () => {