Skip to content

Commit 8edc397

Browse files
committed
docs: added valibot to field validation
1 parent 6b00ad4 commit 8edc397

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<input type="text" v-model="value" />
3+
{{ errorMessage }}
4+
</template>
5+
6+
<script setup>
7+
import { useField } from 'vee-validate';
8+
import { toTypedSchema } from '@vee-validate/valibot';
9+
import { string, email, minLength } from 'valibot';
10+
11+
const { value, errorMessage } = useField('email', toTypedSchema(string([minLength(1, 'Required'), email()])));
12+
</script>

docs/src/pages/guide/composition-api/custom-inputs.mdx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,32 @@ Then you can wrap your zod field schemas with `toTypedSchema` function. [More on
100100

101101
<Repl files={{ 'App.vue': 'CompositionInputFieldZod' }} client:only />
102102

103-
### Validating with global validators
103+
### Validating with Valibot
104+
105+
You can use [Valibot](https://valibot.dev/) to validate your fields, however, you will need to add `@vee-validate/valibot` to your dependencies.
106+
107+
```sh
108+
# with npm
109+
npm i @vee-validate/valibot
110+
# with pnpm
111+
pnpm add @vee-validate/valibot
112+
# with yarn
113+
yarn add @vee-validate/valibot
114+
```
115+
116+
Then you can wrap your valibot field schemas with `toTypedSchema` function. [More on that here](/guide/composition-api/typed-schema).
117+
118+
<Repl files={{ 'App.vue': 'CompositionInputFieldValibot' }} client:only />
119+
120+
### Other validation providers
121+
122+
#### Validating with global validators
104123

105124
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.
106125

107126
You can refer to the full guide on global rules [here](/guide/global-validators).
108127

109-
### Validating with functions
128+
#### Validating with functions
110129

111130
Another option is to just use any 3rd party validation tool you prefer.
112131

0 commit comments

Comments
 (0)