Connect a Valibot schema to useForm's onValidate callback.
Client-side form validation
Conform · Function
parseWithValibot validates FormData or URLSearchParams with a Valibot schema and returns Conform's submission overview. It supports schema factories, parse options, and configurable automatic coercion.
parseWithValibot reads FormData or URLSearchParams and validates it against a Valibot schema, returning Conform's submission overview. It can also receive a schema-producing function and optional parse configuration; automatic empty-value stripping and type coercion are enabled unless explicitly disabled.
parseWithValibot(payload, options)| Name | Type | Description |
|---|---|---|
payload | FormData | URLSearchParams | FormData or URLSearchParams submitted by the form. |
options | object | Options containing the Valibot schema or schema factory, optional parse information, and optional coercion control. |
options.schema | BaseSchema | (intent) => BaseSchema | Valibot schema or function returning a schema. |
options.info | ParseInfo | Valibot parse configuration and language selection. |
options.disableAutoCoercion | boolean | Disables automatic type coercion when true. |
A Conform submission overview containing the parsed validation result.
import { parseWithValibot } from '@conform-to/valibot';
import { useForm } from '@conform-to/react';
import { email, object, pipe, string } from 'valibot';
const schema = object({
email: pipe(string(), email()),
});
function ExampleForm() {
const [form] = useForm({
onValidate({ formData }) {
return parseWithValibot(formData, { schema });
},
});
return <form id={form.id} method="post" />;
}Pass the submitted form data and Valibot schema to obtain Conform's validation submission.
Client-side form validation
Server-side action validation
Intent-specific validation
It accepts submitted FormData or URLSearchParams plus options containing a Valibot schema. The result is a Conform submission overview containing the parsed validation outcome.
Follow-up: How can schema selection depend on the submission intent? Pass a function as options.schema; it receives the intent and returns the appropriate Valibot schema.
The payload is the submitted FormData or URLSearchParams object. The options object supplies either a Valibot schema or a function that returns one, and may also include Valibot parse configuration.
Follow-up: What can options.info control? It provides Valibot parse configuration and selects the language used while parsing form data.
Automatic coercion can be disabled with options.disableAutoCoercion set to true. When disabled, the caller is responsible for preprocessing and parsing form values.
Follow-up: What happens when the option is omitted? Conform introspects the schema and internally adds preprocessing through its coercion helper.
coerceFormValueuseFormValibot schemaconformValibotMessage