From c86d5861801e05c9b9bf0d86a016cb67a7424ad1 Mon Sep 17 00:00:00 2001 From: svetlana Date: Mon, 8 Apr 2024 18:23:29 +0300 Subject: [PATCH] added a check for forbidden characters in username --- frontend/src/locales/en.json | 2 +- frontend/src/locales/ru.json | 2 +- frontend/src/utils/validationSchemas.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index c8d7bdd7..df51166d 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -48,7 +48,7 @@ "emailIsUsed": "This email address is already being used", "incorrectEmail": "Incorrect email", "incorrectPassword": "Only Latin letters, numbers and punctuation are allowed", - "incorrectUsername": "There must be no spaces or slashes in the username", + "incorrectUsername": "Only Latin letters, numbers and symbols - _ are allowed", "passwordLength": "From 8 to 30 characters", "requiredField": "Required field", "singleWord": "Allowed latin letters, numbers and symbols - _ .", diff --git a/frontend/src/locales/ru.json b/frontend/src/locales/ru.json index 8b4a0422..3ef64bd5 100644 --- a/frontend/src/locales/ru.json +++ b/frontend/src/locales/ru.json @@ -48,7 +48,7 @@ "emailIsUsed": "Этот адрес уже зарегистрирован", "incorrectEmail": "Некорректная электронная почта", "incorrectPassword": "Допустимы только латинские буквы, цифры и знаки препинания", - "incorrectUsername": "В логине не должно быть пробелов или символов слеша", + "incorrectUsername": "Допустимы только латинские буквы, цифры, и символы - _", "passwordLength": "От 8 до 30 символов", "requiredField": "Обязательное поле", "singleWord": "Допустимы буквы латинского алфавита, цифры и символы -_ .", diff --git a/frontend/src/utils/validationSchemas.js b/frontend/src/utils/validationSchemas.js index 2fb89665..227841e5 100644 --- a/frontend/src/utils/validationSchemas.js +++ b/frontend/src/utils/validationSchemas.js @@ -4,7 +4,7 @@ import { string } from 'yup'; const USERNAME_MIN_LENGTH = 3; const USERNAME_MAX_LENGTH = 16; -const USERNAME_REGEX = /^[^\s/\\]*$/; +const USERNAME_REGEX = /^[a-zA-Z0-9_-]+$/; const PASSWORD_MIN_LENGTH = 8; const PASSWORD_MAX_LENGTH = 30;