@formsignals/validation-adapter-zod
v0.4.7
Published
Validation adapter for zod enabling the usage of zod schemas with signal forms
Downloads
328
Maintainers
Readme
The zod validation adapter for form management with Preact Signals.
Features
- TypeScript - Written in TypeScript with full type support for optimal DX.
- Reactivity - Reactivity without abstractions thanks to Preact Signals.
- Validation - Built-in validation support, including adapters for validation schema libraries.
- Transformations - Transform values for the specific needs of your input fields.
- Async Data - Easily manage async initialisation, validation and submission.
- Arrays + Dynamic Objects - Utilize arrays and dynamic objects within your forms.
Install
npm install @formsignals/validation-adapter-zodIf you have not installed zod yet, you will need to install it as well:
npm install zodQuickstart
A form or field needs to receive a validation adapter during configuration to be able to use zod schemas.
const form = new FormLogic({
defaultValues: {
name: '',
email: '',
},
validationAdapter: ZodAdapter,
});Then you can create a field instance and configure it with a zod schema:
const nameField = form.getOrCreateField('name', {
validate: Zod.string().min(3),
});