@appwise/forms
v0.0.32
Published
Downloads
99
Keywords
Readme
Installation
pnpm i @appwise/forms
The validation of this package relies on Zod.
Documentation
Refer to the documentation for a more in depth look.
Usage Example
<script setup lang="ts">
import { useForm } from '@appwise/forms'
import { z } from 'zod'
// Create a schema
const exampleForm = z.object({
name: z.string().min(1),
email: z.string().email(),
})
// Parse the schema to `useForm` along with a function to handle the submit.
// Optionally, you can also pass a object to prepare the form.
const form = useForm(exampleForm,
// Loads the form with initial data
{
name: 'Foo',
email: '[email protected]',
},
)
// Now you can register fields on the form, which are fully typed.
// These fields will handle the actual data-binding
const name = form.register('name')
</script>
<template>
<CustomInput v-bind="name" />
<CustomInput v-bind="form.register('email')" />
</template>