Package Exports
- conform-to-valibot
- conform-to-valibot/dist/index.js
- conform-to-valibot/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (conform-to-valibot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
conform-to-valibot
API Reference
parse
It parses the formData and returns a submission result with the validation error. If no error is found, the parsed data will also be populated as submission.value.
import { useForm } from '@conform-to/react';
import { parse } from 'conform-to-valibot';
import { object, string } from 'valibot';
const schema = object({
email: string('Email is required' ),
password: string('Password is required' ),
});
function ExampleForm() {
const [form, { email, password }] = useForm({
onValidate({ formData }) {
return parse(formData, {
schema,
});
},
});
// ...
}Or when parsing the formData on server side (e.g. Remix):
import { useForm } from '@conform-to/react';
import { parse } from 'conform-to-valibot';
import { object } from 'valibot';
const schema = object({
// Define the schema with valibot
});
export async function action({ request }) {
const formData = await request.formData();
const submission = await parse(formData, {
schema,
});
if (!submission.value || submission.intent !== 'submit') {
return submission;
}
// ...
}