Skip to content

Lesson 6 #75

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

Open
wants to merge 8 commits into
base: lesson-6
Choose a base branch
from
Open

Conversation

maslovandrii
Copy link

No description provided.

}

getCachedValue = (cachedValue, str) => {
for(let key in cachedValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let => const


function EmailValidator(str) {
BaseValidator.call(this);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убери лишние пустые строки до и после объявления переменной

let result = getCachedValue(cachedValue, str);
if(result === undefined) { //Валидировать дату через регулярное выражение, наверно, не самое правильное решение. Сильно длинно и нечитаемо... Но вариант через кучу if, пожалуй, не лучше... но если надо перепишу
cachedValue[`${str}`] = /^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-.\/])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(str);
return /^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-.\/])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(str) || false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынеси регулярку в константу и юзай ее

let result = getCachedValue(cachedValue, str);
if(result === undefined) {
cachedValue[`${str}`] = /\([0-9]{3}\)\s[0-9]{3}-[0-9]{2}-[0-9]{2}/.test(str);
return /\([0-9]{3}\)\s[0-9]{3}-[0-9]{2}-[0-9]{2}/.test(str) || false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут также
можно все регекспы вынести в верх файла и юзать их по ходу дела


this.ucWords = (str) => {
let myArray = str.split(' ');
const n = myArray.length;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n переименуй

const n = myArray.length;

for(let i = 0; i < n; i++) {
myArray[i] = this.ucFirst(myArray[i]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myArray тоже перименуй

return /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(str) || false
}

this.isDate = (str) => { //Валидировать дату через регулярное выражение, наверно, не самое правильное решение. Сильно длинно и нечитаемо... Но вариант через кучу if, пожалуй, не лучше... но если надо перепишу

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комент пиши до функции
регулярку сделай так же, как в файле выше

@@ -0,0 +1,18 @@
function Worker(name1, surname1, rate1, days1) {
this.name = name1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name1 и тд переименуй
name1 => why not?


this.setRate = (rate2) => {
rate = rate2;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rate2 и подобное дальше переименуй


ucWords(str) {
let myArray = str.split(' ');
const n = myArray.length;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n, myArray, str переименуй

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants