Installations
npm install conform-to-valibot
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
20.18.1
NPM Version
10.2.4
Score
80.7
Supply Chain
98.5
Quality
90.7
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (99.84%)
JavaScript (0.16%)
Developer
chimame
Download Statistics
Total Downloads
43,164
Last Day
57
Last Week
3,438
Last Month
15,990
Last Year
43,162
GitHub Statistics
44 Stars
53 Commits
6 Forks
1 Watching
1 Branches
5 Contributors
Package Meta Information
Latest Version
1.12.2
Package Id
conform-to-valibot@1.12.2
Unpacked Size
30.13 kB
Size
5.45 kB
File Count
7
NPM Version
10.2.4
Node Version
20.18.1
Publised On
07 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
43,164
Last day
-71.1%
57
Compared to previous day
Last week
6%
3,438
Compared to previous week
Last month
110%
15,990
Compared to previous month
Last year
2,158,000%
43,162
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
conform-to-valibot
Installation
1npm install @conform-to/react valibot conform-to-valibot
API Reference
parseWithValibot
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
.
1import { useForm } from '@conform-to/react'; 2import { parseWithValibot } from 'conform-to-valibot'; 3import { object, string } from 'valibot'; 4 5const schema = object({ 6 email: string('Email is required' ), 7 password: string('Password is required' ), 8}); 9 10function ExampleForm() { 11 const [form, { email, password }] = useForm({ 12 onValidate({ formData }) { 13 return parseWithValibot(formData, { 14 schema, 15 }); 16 }, 17 }); 18 19 // ... 20}
Or when parsing the formData on server side (e.g. Remix):
1import { useForm } from '@conform-to/react'; 2import { parseWithValibot } from 'conform-to-valibot'; 3import { object } from 'valibot'; 4 5const schema = object({ 6 // Define the schema with valibot 7}); 8 9export async function action({ request }) { 10 const formData = await request.formData(); 11 const submission = await parseWithValibot(formData, { 12 schema, 13 }); 14 15 // Send the submission back to the client if the status is not successful 16 if (submission.status !== 'success') { 17 return submission.reply(); 18 } 19 20 // ... 21}
getValibotConstraint
A helper that returns an object containing the validation attributes for each field by introspecting the valibot schema.
1import { getValibotConstraint } from "conform-to-valibot"; 2import { useForm } from "@conform-to/react"; 3import { object, string, minLength, maxLength, optional } from "valibot"; 4 5const schema = object({ 6 title: string([minLength(10), maxLength(100)]), 7 description: optional(string([minLength(100), maxLength(1000)])), 8}); 9 10function Example() { 11 const [form, fields] = useForm({ 12 constraint: getValibotConstraint(schema), 13 }); 14 15 // ... 16}
No vulnerabilities found.
No security vulnerabilities found.