Skip to content

Conversation

@kevinkosterr
Copy link
Owner

Summary

This pull request introduces a new way to create form schemas that are inspired by how Zod defines it's validation schemas. Essentially what this means is that instead of having to write JSON objects to define a schema, you can define a schema using builders.

The current way of defining a schema:

const form = ref({
 model: { ... },
 fields: [ ... ],
 groups: [ ... ]
})

A new way to define a schema would look something like:

import { f } from '@kevinkosterr/vue3-form-generator'

const schema = f.schema(
  { textModel: '', selectModel: '' } // Your regular model definition
  f.text('textFieldName', 'textModel').placeholder('This is a placeholder'),
  f.select('selectFieldName', 'selectModel').addOption('Test', 'test').multiple(false)
)

To define a field, and get it's JSON object you could do something like this:

import { f } from '@kevinkosterr/vue3-form-generator'

const selectFieldSchema = f.select('name', 'modelKey').addOption('Foo', 'foo').build()

Checklist

  • The commits in this PR follow the commit guidelines
  • The pull request was issued to the master branch (if not part of a release)

What kind of change(s) does this PR introduce? (Check at least one)

  • Bug fix 🐛 - fix(...)
  • Feature - feat(...)
  • Documentation - docs(...)
  • Introduces or modifies test(s) - test(...)
  • Other (please describe)

@kevinkosterr kevinkosterr added 🔼 enhancement New feature or request 🧪 tests Adds or fixes tests labels Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔼 enhancement New feature or request 🧪 tests Adds or fixes tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants