Replies: 1 comment 3 replies
-
Hello, well the following expression:
Won't work because We can think of a few ways to make import { defineRule } from 'vee-validate';
defineRule({
myCustomRuleFn,
myOtherCustomRuleFn,
yetAnotherCustomRuleFn,
}); Would that be sufficient or do you want to avoid using Another thing we could do is to allow object with methods as a rule expression so something like this: <Field
...
:rules="{ myCustomRuleFn }"
...
></Field> The problem with that is there won't be a way to pass in any arguments, so maybe it is not the ideal approach here. Happy to hear your thoughts and other suggestions! |
Beta Was this translation helpful? Give feedback.
-
I understand that there are at least 3 different ways to apply a rule to a field:
As a string:
As an object:
As a function:
And, some combination of the 3.
However, I've noticed that not all the different ways work with standard functions. Seems like only ones pre-defined using
defineRule
will work.for example, this will not work with a custom function that is NOT pre-defined:
Am I missing something? I feel like having to pre-define them globally shouldn't be necessary unless you want to use them as a string. But I'd rather not have to create a Plugin just to pre-define a bunch of rules globally. Schema based Form rules seem like the preferred way based on the docs; my preferred way is to do it per-field.
If field-based custom rule functions can't be applied (in all the different methods) w/o globally defining them first, is this something that could be changed possibly? I'd love to hear thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions