@stackform/valibot
v1.1.0
Published
Valibot validation integration for StackForm
Maintainers
Readme
@stackform/valibot
Valibot integration for StackForm. Extracts constraints (required, min, max, minLength, maxLength) from a Valibot schema and validates field values against it — same API surface as @stackform/zod, picked at install time.
Install
npm install @stackform/valibot valibotPeer dependencies: react >= 18, react-dom >= 18, valibot >= 1.0.0.
Usage
import * as v from 'valibot'
import { useValibotField } from '@stackform/valibot'
import { TextField } from '@stackform/core'
const emailSchema = v.pipe(
v.string(),
v.email(),
v.minLength(3),
v.maxLength(120)
)
function EmailField() {
const { fieldProps, constraints } = useValibotField('email', emailSchema)
return (
<TextField
name="email"
label="Email"
required={constraints.required}
maxLength={constraints.maxLength}
{...fieldProps}
/>
)
}Works with any adapter — RHF, TanStack, or native — by handing the returned validate function to your form library or relying on StackForm's per-field validation.
Docs
Constraint extraction, error messages, and adapter integration: stack-form-docs.vercel.app
License
MIT
