password custom validation rule
See original GitHub issueHi Logaretm,
I am trying to add password validation using a regex I found online and adding it as a custom rule. The idea is that one should have a password that is strong enough. However, I seem to get a problem adding the regex. I add the code example below.
Next, I tried something else which you can see in the second piece of code. This time there is no regex error, but there is an error in regards to attach() not being a function.
Help or hints are much appreciated.
All best, Max
import { Validator } from 'vee-validate';
Validator.extend('verify_password', {
getMessage: field => `The password must contain at least: 1 uppercase letter, 1 lowercase letter, 1 number, and one special character (E.g. , . _ & ? etc)`,
validate: value => resolve({
valid: ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,}).test(value);
});
});
Validator.attach('password', 'required|min:8|verify_password');
import { Validator } from 'vee-validate';
Validator.extend('verify_password', {
getMessage: field => `The password must contain at least: 1 uppercase letter, 1 lowercase letter, 1 number, and one special character (E.g. , . _ & ? etc)`,
validate: value => {
var strongRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
return strongRegex.test(value);
}
});
Validator.attach('password', #'required|min:8|verify_password');
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Laravel password validation rule - Stack Overflow
The password contains characters from at least three of the ... A Custom Laravel Validation Rule will allow developers to provide a custom...
Read more >Password Validation Rule Object in Laravel 8
Coming to @laravelphp: Password Rule Object. This rule object allows to easily customise the password complexity requirements. You may also ...
Read more >How to Customize Password Validation | Curity Identity Server
Create a procedure by using the Admin UI. Click on System->Procedure->New procedure. Give it the name password-strength and make sure the type is...
Read more >Validation - Laravel - The PHP Framework For Web Artisans
Validating Files; Validating Passwords; Custom Validation Rules ... Laravel includes a wide variety of convenient validation rules that you may apply to ...
Read more >The new custom password rule object in Laravel 8.x
For instance, if you want to apply a password validation rule which ensures it's required, should be a string, have an additional password...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I figured it out. Use it as below
Then:
<input type="text" name="password" v-model="password" v-validate="'required|min:8|verify_password'" data-vv-as="New Password">
Hi, the example link can not work now
All best