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: README.md
+13-15Lines changed: 13 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,27 +15,25 @@ It's generally a good idea to check that you're all set up early in the developm
15
15
## Installation
16
16
17
17
```shell
18
-
npm install -D vite-plugin-valibot-env valibot
18
+
npm install -vite-plugin-valibot-env valibot
19
19
```
20
20
21
21
## Usage
22
22
23
23
Let's start with a very basic example
24
24
25
25
```javascript
26
-
import { defineConfig } from'vite';
27
-
import*asvfrom'valibot';
28
-
importvalibotfrom'vite-plugin-valibot-env';
26
+
import { defineConfig } from"vite";
27
+
import*asvfrom"valibot";
28
+
importvalibotfrom"vite-plugin-valibot-env";
29
29
30
30
constschema=v.object({
31
31
VITE_API_ENDPOINT:v.pipe(v.string(), v.url()),
32
-
VITE_LOCALE:v.literal('en_US'),
32
+
VITE_LOCALE:v.literal("en_US"),
33
33
});
34
34
35
35
exportdefaultdefineConfig({
36
-
plugins: [
37
-
valibot(schema),
38
-
]
36
+
plugins: [valibot(schema)],
39
37
});
40
38
```
41
39
@@ -51,24 +49,24 @@ export default defineConfig({
51
49
#### `options.ignoreEnvPrefix`
52
50
53
51
Type: `boolean`
54
-
Default: `false`
52
+
Default: `false`
55
53
56
54
Setting this to `true` will also validate unprefixed environment variables.
57
55
58
56
> [!TIP]
59
-
> Vite uses a [prefix](https://vitejs.dev/config/shared-options.html#envprefix) to prevent leaking all environment variables into your code. The same limitation applies to the validator. However, there might be use cases where you want validate unprefixed environment variables as well, e.g. `HOST` and `PORT` to configure the Vite server.
57
+
> Vite uses a [prefix](https://vitejs.dev/config/shared-options.html#envprefix) to prevent leaking all environment variables into your code. The same limitation applies to the validator. However, there might be use cases where you want validate unprefixed environment variables as well, e.g. `HOST` and `PORT` to configure the Vite server.
60
58
61
59
#### `options.transformValues`
62
60
63
61
Type: `boolean`
64
-
Default: `false`
62
+
Default: `false`
65
63
66
64
Setting this to `true` will try and transform string values to their respective types. Supports booleans, integers, floats, and `null`.
67
65
68
66
#### `options.language`
69
67
70
68
Type: `string`
71
-
Default: `undefined`
69
+
Default: `undefined`
72
70
73
71
Language ID for localized error messages.
74
72
@@ -78,14 +76,14 @@ Language ID for localized error messages.
78
76
#### `options.onBeforeIssues`
79
77
80
78
Type: `function`
81
-
Default: `undefined`
79
+
Default: `undefined`
82
80
83
81
A callback function executed after any issues have been printed.
84
82
85
83
#### `options.onAfterIssues`
86
84
87
85
Type: `function`
88
-
Default: `undefined`
86
+
Default: `undefined`
89
87
90
88
A callback function executed after all issues have been printed.
91
89
@@ -95,7 +93,7 @@ A callback function executed after all issues have been printed.
95
93
#### `options.throwError`
96
94
97
95
Type: `boolean`
98
-
Default: `false`
96
+
Default: `false`
99
97
100
98
> [!CAUTION]
101
99
> This option exists for testing purposes and is not recommended for other use.
0 commit comments