diff --git a/src/shared/constants/forms/validationParams.ts b/src/shared/constants/forms/validationParams.ts index 6055295d..a66f80bb 100644 --- a/src/shared/constants/forms/validationParams.ts +++ b/src/shared/constants/forms/validationParams.ts @@ -14,6 +14,22 @@ export const EMAIL_VALIDATE = { }, } as const; +export const FOOTER_EMAIL_VALIDATE = { + notWhitespace: { + messages: { en: 'Email must not contain white spaces', ru: 'Адрес электронной почты не должен содержать пробелы' }, + pattern: /^\S+$/, + }, + required: false, + validMail: { + messages: { + en: 'Enter correct email (user@example.com)', + ru: 'Введите правильный адрес электронной почты (user@example.com)', + }, + pattern: + /^(?!.*[_.-]{2})(?!^[_.-])(?!.*[_\\-]$)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,6}$/, + }, +} as const; + export const PASSWORD_VALIDATE = { minLength: 8, notWhitespace: { diff --git a/src/widgets/Footer/view/FooterView.ts b/src/widgets/Footer/view/FooterView.ts index aa1d2542..a9fd45b5 100644 --- a/src/widgets/Footer/view/FooterView.ts +++ b/src/widgets/Footer/view/FooterView.ts @@ -496,7 +496,7 @@ class FooterView { cssClasses: [styles.subForm], tag: 'form', }); - const email = new InputFieldModel(FORM_FIELDS.EMAIL_NOT_LABEL_TEXT, FORM_VALIDATION.EMAIL_VALIDATE); + const email = new InputFieldModel(FORM_FIELDS.EMAIL_NOT_LABEL_TEXT, FORM_VALIDATION.FOOTER_EMAIL_VALIDATE); const inputFieldElement = email.getView().getHTML(); const inputHTML = email.getView().getInput().getHTML(); if (inputFieldElement instanceof HTMLLabelElement) {