Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.7 KB

File metadata and controls

49 lines (36 loc) · 1.7 KB

Signal Form Banner

validation-adapter-zod-version
validation-adapter-zod-bundle

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-zod

If you have not installed zod yet, you will need to install it as well:

npm install zod

Quickstart

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),
});