-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat(useForm): Set errors only for touched fields on 'blur' validation mode #31
base: main
Are you sure you want to change the base?
feat(useForm): Set errors only for touched fields on 'blur' validation mode #31
Conversation
I would like to express my appreciation for your contribution. Currently, the provided code is not performing as expected. I am wondering if you might have any insights or suggestions related to this issue? <script setup lang="ts">
import { useForm } from '@vorms/core'
const { errors, register } = useForm({
initialValues: {
name: {
first: 'John',
last: 'Doe'
},
},
validateMode: 'blur',
validate() {
return {
name: {
first: 'Please enter a first name',
last: 'Please enter a last name'
}
}
},
onSubmit(values) {
// Your submission logic here
}
})
const { value: nameFirst, attrs: nameFirstAttrs } = register('name.first')
const { value: nameLast, attrs: nameLastAttrs } = register('name.last')
</script>
<template>
<div>
<pre>{{ errors }}</pre>
<input v-model="nameFirst" type="text" v-bind="nameFirstAttrs">
<input v-model="nameLast" type="text" v-bind="nameLastAttrs">
</div>
</template> Once we move focus away from the first input field (
|
Thanks for the appreciation π . Anyways, this is happening because my code does not support deep nested attributes (I didn't know vorms supported it). I'll update the PR when I have the time |
8ab096f
to
d68d455
Compare
@Mini-ghost PR Updated |
Is this PR still in progress? I hope it gets merged soon so I can apply it to my form. And as always, thank you for your hard work. |
It is ready to merge, we just need the package author to approve (or request changes) |
I sincerely apologize for the extended delay in addressing this issue. Upon reevaluation, I have reconsidered the problem at hand. It occurred to me that there might be a potential solution wherein any validation mode could offer the choice to display either the complete set of error messages or solely those associated with 'dirty' fields. The current proposed approach involves introducing the concept of Thank you for your understanding and patience regarding this matter. |
Sounds good, I like the new approach and I'm excited to see how it turns out, thanks |
π Linked issue
#29
β Type of change
π Description
When a field gets blurred on 'blur' validation mode, it updates the error object with just the fields that have been touched. This solves the problem of having all fields showing errors when just the first one was blurred.
Resolves #29
π Checklist