Skip to content

Commit 28717ad

Browse files
authored
Merge pull request #15 from natalya87324/master
2 parents 489a12e + b20a9ea commit 28717ad

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

js/upload-photo.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { toggleClass, isEscapeKey, showWrongFileMessage } from './util.js';
22
import { updateScale, resetScale, updateEffect, resetSlider } from './update-photo-mode.js';
33
import { sendData } from './api.js';
44

5+
const HASHTAG_REGEX = /^#[a-zа-яё0-9]{1,19}$/i;
56
const HASHTAG_MAX_COUNT = 5;
67
const FILE_TYPES = ['gif', 'jpg', 'jpeg', 'png'];
78
const DESCRIPTION_MAX_LENGTH = 140;
@@ -47,7 +48,7 @@ const validatePhotoDescription = (description) => description.length < DESCRIPTI
4748

4849
const validateHashtags = (value) => {
4950
errorMessage = '';
50-
const hashtagRegex = /^#[a-zа-яё0-9]{1,19}$/i;
51+
5152
const inputText = value.toLowerCase().trim();
5253

5354
if (!inputText) {
@@ -66,7 +67,7 @@ const validateHashtags = (value) => {
6667
error: 'Хэштег должен начинаться с символа #'
6768
},
6869
{
69-
check: inputArray.some((item, index, array) => array.includes(item, index + 1)),
70+
check: inputArray.some((item, index, arrayItems) => arrayItems.includes(item, index + 1)),
7071
error: 'Хэштеги не должны повторяться'
7172
},
7273
{
@@ -82,7 +83,7 @@ const validateHashtags = (value) => {
8283
error: `Нельзя указать больше ${HASHTAG_MAX_COUNT} хэштегов`
8384
},
8485
{
85-
check: inputArray.some((item) => !hashtagRegex.test(item)),
86+
check: inputArray.some((item) => !HASHTAG_REGEX.test(item)),
8687
error: 'Хештег содержит недопустимые символы'
8788
}
8889
];
@@ -114,9 +115,9 @@ const toggleModal = () => {
114115
};
115116

116117
const resetForm = () => {
117-
const errorArray = document.querySelectorAll('.img-upload__field-wrapper--error');
118-
if (errorArray.length !== 0) {
119-
errorArray.forEach((error) => {
118+
const errors = document.querySelectorAll('.img-upload__field-wrapper--error');
119+
if (errors.length !== 0) {
120+
errors.forEach((error) => {
120121
error.textContent = '';
121122
});
122123
}

0 commit comments

Comments
 (0)