You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/guide/composition-api/getting-started.mdx
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,13 +280,51 @@ There is a known issue with Zod's `refine` and `superRefine` not executing whene
280
280
281
281
</DocTip>
282
282
283
-
### Validating with global validators
283
+
### Validating with Valibot
284
+
285
+
You can also use [Valibot](https://valibot.dev/) which is is a schema library with bundle size, type safety and developer experience in mind. It is a great alternative to Yup and Zod if bundle size is a concern. You will need to use the `@vee-validate/valibot` package to use valibot schemas.
286
+
287
+
```sh
288
+
# with npm
289
+
npm i @vee-validate/valibot
290
+
# with pnpm
291
+
pnpm add @vee-validate/valibot
292
+
# with yarn
293
+
yarn add @vee-validate/valibot
294
+
```
295
+
296
+
Then you can wrap your Valibot schemas with `toTypedSchema` function which allows vee-validate to infer form input and output types. [More on that here](/guide/composition-api/typed-schema).
Another option is using `@vee-validate/rules` which have been historically bundled with past versions of vee-validate. It includes rules that can be defined globally and then used anywhere using Laravel-like string expressions.
286
324
287
325
You can refer to the full guide on global rules [here](/guide/global-validators).
288
326
289
-
### Validating with functions
327
+
####Validating with functions
290
328
291
329
Another option is to just use any 3rd party validation tool you prefer, something like [`validator.js`](https://github.com/validatorjs/validator.js/). Here is a quick example:
But note that this does not change the input or output types of the casted fields. The cast will only occur when setting the initial value and when the values are submitted.
175
+
But note that this does not change the input or output types of the casted fields. The cast will only occur when setting the initial value and when the values are submitted in the submission handler.
[Valibot](https://valibot.dev/) is a schema library with bundle size, type safety and developer experience in mind. It is a great alternative to Yup and Zod if bundle size is a concern.
284
+
285
+
You can use valibot as a typed schema with the `@vee-validate/valibot` package:
286
+
287
+
```sh
288
+
# npm
289
+
npm install @vee-validate/valibot
290
+
# yarn
291
+
yarn add @vee-validate/valibot
292
+
# pnpm
293
+
pnpm add @vee-validate/valibot
294
+
```
295
+
296
+
The `@vee-valdiate/valibot` package exposes a `toTypedSchema` function that accepts any valibot schema. Which then you can pass along to `validationSchema` option on `useForm`.
297
+
298
+
This makes the form values and submitted values typed automatically and caters for both input and output types of that schema.
But note that this does not change the input or output types of the casted fields. The cast will only occur when setting the initial value and when the values are submitted in the submission handler.
0 commit comments