Closed de1ck closed 5 years ago
Sorry, but I have no clue what is the problem here. Can you fill the template and describe the problem in detail? A live example might help as well.
@logaretm v-validata support on String and simple Object https://baianat.github.io/vee-validate/api/directive.html I hope v-validata support Custom Rules similar syntax : https://baianat.github.io/vee-validate/guide/custom-rules.html#custom-rules
examle:
<input v-validate="rule">
data() {
return {
rule: {
getMessage(field, args) {
// will be added to default locale messages.
// Returns a message.
},
validate(value, args) {
// Returns a Boolean or a Promise that resolves to a boolean.
}
}
}
}
@de1ck This won't work, you should use Validator.extend
to make sure your rule can be used, you should read the following sections here
So you need to do this:
// anywhere in your code
Validator.extend('rule', {
getMessage(field, args) {
// will be added to default locale messages.
// Returns a message.
},
validate(value, args) {
// Returns a Boolean or a Promise that resolves to a boolean.
}
});
Then you can use it like this:
<input v-validate="'rule'">
@de1ck This won't work, you should use
Validator.extend
to make sure your rule can be used, you should read the following sections hereSo you need to do this:
// anywhere in your code Validator.extend('rule', { getMessage(field, args) { // will be added to default locale messages. // Returns a message. }, validate(value, args) { // Returns a Boolean or a Promise that resolves to a boolean. } });
Then you can use it like this:
<input v-validate="'rule'">
If I do this in my code, its throws an error at console like No such validator 'RULE' exists.
Rules are case sensitive, the error message you posted suggests you used an uppercase rule name.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
v-validata = 'validator '
const validator = { getMessage(field, args) { // will be added to default locale messages. // Returns a message. }, validate(value, args) { // Returns a Boolean or a Promise that resolves to a boolean. } };
Describe the solution you'd like A clear and concise description of what you want to happen.
https://baianat.github.io/vee-validate/guide/custom-rules.html#custom-rules
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
refer to element-ui form validate
Additional context Add any other context or screenshots about the feature request here.