-
-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ref (and possibly computed) #1219
Comments
const count = ref(0);
const newRules = {
value: {
maxLength: maxLength(5)
}
}
const newerV$ = useVuelidate(newRules, count); Should be changed to const count = ref(0);
const newRules = {
count: {
maxLength: maxLength(5)
}
}
const newerV$ = useVuelidate(newRules, { count }); The usage is actually noted at https://vuelidate-next.netlify.app/advanced_usage.html#using-an-object-of-refs , although, I am not a particular fan of writing it like this. In my personal option, the parameter positions of rules/values is backwards. If it was created to be values/rules , then you could define your values object (or lets say also allowing a direct ref, rather than being forced into always needing an object), then you could define your rules with intellisense. I find myself often times working backwards when using the current api. Although, this doesn't really pertain to this issue |
Thanks, I understand now. You raise a good point with intellisense though. Vuelidate is great once it works, but I’ve already lost hours of time due to the intellisense issue alone. When it doesn’t work, I’m frantically trying to change everything until I realize oep, someone changed a type somewhere but everything still build correctly and nobody realized they needed to change the vuelidate schema. It’s incredibly frustrating. If intellisense will not work with vuelidate, I would at least want it to throw an error so I can debug in the console. Right now it’s not giving me anything. It would have likely helped me out with this problem, too. |
Is your feature request related to a problem? Please describe.
The Vuelidate API exposes a
useVuelidate
function for creating a validation object, which is frequently given a rules object and reactive state to apply it to. This function does not seem to work with refs. However, Vue's own documentation recommends ref over reactive.Describe the solution you'd like
This huge missed opportunity seems to stem from the fact that you can't use the
value
keyword inside your rules (as to my understanding). The perfect solution would be to remove all reserved keywords from rules and instead apply it indiscriminately.Describe alternatives you've considered
This might be a big rewrite. A simpler alternative would be to rename vuelidate's OWN
value
property to$value
, being more inline with their current naming scheme and requiring minimal changes from developers to update. This of course doesn't solve the underlying issue that rules has reserved keywords, but it would at least allow for objects who already usevalue
(which are a lot) as their main accessor to be used by vuelidate.Additional context
The text was updated successfully, but these errors were encountered: