Answer
If the schema you pass to useForm is a reactive reference (e.g., a ref or reactive object), changing that reference automatically triggers a re‑validation of all currently touched fields. No manual call to validate is required. If the schema is a plain object, VeeValidate does not watch it and you must invoke validation yourself after updating the schema.
Confirmed facts (from VeeValidate v4+ behavior)
- When
useForm receives a schema argument that is a reactive ref, VeeValidate sets up a watcher on that ref.
- On each change of the ref, the watcher calls the internal
validateAll method, which runs the new schema against every field’s current value and updates error states.
- Field‑level re‑validation respects each field’s
immediate mode: with immediate:true the field validates on every input; otherwise it validates on blur or when the schema watcher triggers a re‑run.
- If the schema is a plain object (non‑reactive), no watcher is created; error messages stay stale until you call
handleSubmit, validate, or trigger a user interaction that runs validation.
Steps to ensure consistency when the schema changes
- Declare the schema as a reactive ref:
import { ref } from 'vue'
import { useForm } from 'vee-validate'
const schema = ref(initialSchema) // <-- reactive
const { handleSubmit, errors } = useForm({ schema })
- When you need to update the schema, replace the ref’s value (or assign a new reactive object):
// Example: change validation rules based on a select
schema.value = newSchemaBasedOnSelection
- VeeValidate will automatically re‑validate all touched fields; you can inspect
errors in the template to see updated messages.
- If you are unable to make the schema reactive (e.g., it comes from an external non‑reactive source), wrap it in a
ref before passing it to useForm, or call validate manually after updating:
// Manual fallback
schema = newPlainObject
await validate() // returns a promise with results
Diagnostic detail needed
To confirm whether automatic re‑validation will work for your case, please tell me: Are you passing a reactive ref (e.g., ref or reactive) to the schema option of useForm?
Verification (optional)
In Vue DevTools you can watch the schema ref; when it changes, VeeValidate logs no reactivity warnings and the field error messages update instantly.