I am working on a project, where I use laravel-vue-starter as a base template.
I wants to use a custom validation for password. So I created a resources\assets\js\validators\passwordValidators.js file with code:
import { Validator } from 'vee-validate';
Validator.extend('password', {
getMessage: field => 'Insert a strong password, it should contain Uppercase letter, lowercase letter, number and special character',
validate: value => /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.[\W]).{8,}$/.test(value)
});
But when I am addingv-validate="'password'"
It produce an error[vee-validate] No such validator 'password' exists
Any help will be appreciated.
I think the answer is simple, you are now using a rule name 'password' , but your rule is password.
So try this in your markup (string notation), remove the single quotes.
v-validate = "password"
Or you can also use the object notation when you have more then 1 and complex rules.
v-validate = "{password: true}"
Regards Ben
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With