[Proposal] Stop the defineField bureaucracy: We need a way to map all fields at once
Hi there!
First of all, thanks for the hard work on VeeValidate. It’s a powerful tool, but we need to talk about the developer experience (DX) when dealing with large forms in 2026.
Currently, if I have a form with 20+ fields (which is common in ERP or CRM systems), I have to:
1) Define the interface.
2) Define the Zod/Valibot schema.
3) Define initialValues.
4) And then call defineField 20+ times manually.
This is, quite frankly, a nightmare. It feels like I’m a secretary, not a developer. I've already provided the schema and the initial values - the library already knows every single key of my form. Why am I forced to manually destructure model and props for every single field like it's 2010 again?
**The "Magic Strings" problem:**
Forcing us to use defineField('someField') multiple times leads to:
Redundancy: I'm repeating the same keys 4-5 times across the file.
Refactoring hell: Renaming a field in the schema doesn't automatically rename the string in defineField unless the IDE is having a very lucky day.
Boilerplate bloat: The script setup section becomes a graveyard of const [field, props] = defineField(...).
**The Proposal:**
We need a built-in helper (e.g., defineAllFields or a property on the useForm return object) that automatically maps all keys from initialValues into an object of field-ready structures.
Something like this:
```
const { fields } = useForm({
validationSchema,
initialValues
});
```
And then in template:
`<CustomInput :field="fields.organizationId" />`
or
`<CustomInput v-model="fields.organizationId.model" :meta="meta.organizationId" />`
... etc.
**Why this matters:**
Right now, developers are forced to write their own "FormHelpers" and "Object.keys.reduce" hacks just to make the library usable for enterprise-scale forms. If the goal of VeeValidate is to provide a "Composition API-first" experience, it should feel like Vue, not like a manual data-entry job.
Please consider giving us a way to avoid this manual labor. Our fingers (and keyboards) will thank you.
Best regards,
A developer who is tired of typing defineField 😭
0 条评论