Skip to content

feat(createFormSchema): schema-driven form generation for issue #244#393

Closed
sridhar-3009 wants to merge 4 commits into
vuetifyjs:masterfrom
sridhar-3009:feat/form-schema-244
Closed

feat(createFormSchema): schema-driven form generation for issue #244#393
sridhar-3009 wants to merge 4 commits into
vuetifyjs:masterfrom
sridhar-3009:feat/form-schema-244

Conversation

@sridhar-3009

Copy link
Copy Markdown
Contributor

Summary

Closes #244.

Adds createFormSchema — a composable that sits on top of createForm and createValidation and accepts a typed field-definition object. Returns reactive value refs, per-field v-model bindings, and form-level helpers so consumers can drive a form from a schema without wiring up individual createValidation calls by hand.

API at a glance

const schema = createFormSchema({
  username: {
    default: '',
    rules: ['required', v => String(v).length >= 3 || 'Min 3 characters'],
  },
  email: {
    default: '',
    rules: ['required', 'email'],
  },
})

// Spread onto any input component:
// <TextField v-bind="schema.fields.username" />

const ok = await schema.submit() // validates all fields
schema.reset()                   // restores defaults + clears errors

Each fields.<name> object exposes:

  • modelValue — current value (reactive getter)
  • onUpdate:modelValue — value setter
  • errorMessagesShallowRef<string[]> for displaying validation errors

Design notes

  • UI-agnostic — no dependency on any component library; works with plain <input>, Paper components, or anything else.
  • Typedschema.values.<name> is typed to the default type you provide.
  • DelegatingisValid, isValidating, and submit delegate directly to the underlying FormContext.
  • Accepts all rule formats supported by createValidation: functions, string aliases, and standard schemas (Zod, Valibot, ArkType).

Test plan

  • packages/0/src/composables/createFormSchema/index.test.ts — 12 unit tests covering initial state, field bindings, submit/validation (pass, fail, multi-field, multi-rule), and reset.
  • pnpm typecheck passes
  • pnpm test:run passes (all 6257 tests)
  • pnpm repo:check (knip + sherif) passes

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: fba7633

@johnleider johnleider marked this pull request as draft June 29, 2026 14:36
@sridhar-3009

Copy link
Copy Markdown
Contributor Author

Superseded by #447 which cherry-picks the same change onto a clean branch with all lint errors fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][1.0.0-alpha.5] No support for modular forms via an input schema

1 participant