coding-latte / codinglatte.com-comments

Comments on Coding Latte
0 stars 0 forks source link

posts/angular/cool-password-validation-angular/ #3

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Cool Password Validation – Angular Reactive Forms | Coding Latte - Coding is fun

In this post, we are going to be creating a simple signup form, with email, password and confirm password fields, with custom input validation.

https://codinglatte.com/amp/posts/angular/cool-password-validation-angular/

theotherdy commented 5 years ago

This is very helpful - thank you. A minor correction is that your regex for hasNumber needs to be:

CustomValidators.patternValidator(/\d/, { hasNumber: true }),

ie backslash before the d

mainawycliffe commented 5 years ago

Corrected. Thanks.

hari42726 commented 5 years ago

CustomValidators.patternValidator(/[ [!@#$%^&()_+-=[]{};':"|,.<>/?]/](<mailto:!@#$%^&()_+-=[]{};':"|,.<>/?]/>), { hasSpecialCharacters: true }),

Pattern showing Error. Please help. thanks

mainawycliffe commented 5 years ago

What are you validating?

Regards Maina Wycliffe


From: Haiharan notifications@github.com Sent: Tuesday, July 23, 2019 12:23:17 PM To: coding-latte/codinglatte.com-comments codinglatte.com-comments@noreply.github.com Cc: Maina Wycliffe mainawycliffe@outlook.com; Comment comment@noreply.github.com Subject: Re: [coding-latte/codinglatte.com-comments] posts/angular/cool-password-validation-angular/ (#3)

CustomValidators.patternValidator(/[ [!@#$%^&()+-=[]{};':"|,.<>/?]/](<mailto:!@#$%^&()+-=[]{};':"|,.<>/?]/>), { hasSpecialCharacters: true }),

Pattern showing Error. Please help. thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcoding-latte%2Fcodinglatte.com-comments%2Fissues%2F3%3Femail_source%3Dnotifications%26email_token%3DAC5TXVVOIIOU566ODWPSLTTQA3EYLA5CNFSM4G3J6WQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2SPXQY%23issuecomment-514128835&data=02%7C01%7C%7Cd46968e8e8db4d99a5f208d70f4f65a9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636994705983448048&sdata=gptbjLKsuG5ffKpSk7OjZ8bkWUotz0KUWVJHEan1lXU%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAC5TXVU3J6FYDEH37Y3TVTTQA3EYLANCNFSM4G3J6WQQ&data=02%7C01%7C%7Cd46968e8e8db4d99a5f208d70f4f65a9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636994705983798329&sdata=tr8%2FOGeFvbb18e%2B7zK3wG9Q0lgpjqjNsZ9XWl4sC6a0%3D&reserved=0.

bejgumshirisha commented 4 years ago

I want to allow only few special characters eg: (\, #, $, ^, @, &, %).I have to show error if user types special character rather than the mentioned.I tried with the pattern It is not working. Any help to modify the code. Thanks

mainawycliffe commented 4 years ago

Can you share your code snip please

bejgumshirisha commented 4 years ago

Please find the code.

CustomValidators.patternValidator(/[@#$\^%&]/,
  {
    hasSpecialCharacters: true
  }
), 

If I give any other special character rather the mentioned I have to throw error.

ElCatrapi commented 4 years ago

Thank you sooooooo much, I was attempting to do something similar and you literally saved my life a few hours...

anand94a commented 4 years ago

Thanks @bejgumshirisha. That was really helpful.

hellotaotao commented 4 years ago

Thank you for this tutorial. But I have a question:

In:

static passwordMatchValidator(control: AbstractControl) {

shouldn't it be


static passwordMatchValidator(fg: FormGroup) {
``` ?

Because this validator is attached to the form group, not the form control.