Skip to content

Commit 69566bb

Browse files
committed
chore(readme): remove transform section
1 parent 6dd3731 commit 69566bb

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

README.md

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ ValidateEnv({
8686
// With custom error message
8787
VITE_PORT: Schema.number({ message: 'You must set a port!' }),
8888

89-
// Custom validator
90-
VITE_CUSTOM: (key, value) => {
89+
// Custom validator + transform function
90+
VITE_URL_SUFFIXED_WITH_SLASH: (key, value) => {
9191
if (!value) throw new Error(`Missing ${key}`)
92-
if (value.endsWith('foo')) throw new Error('Cannot end with "foo"')
93-
return value
92+
93+
return value.endsWith('/')
94+
? value
95+
: `${value}/`
9496
},
9597
})
9698
```
@@ -176,30 +178,6 @@ export const env: ImportMetaEnvAugmented = import.meta.env;
176178

177179
By using `env` instead of `import.meta.env` in your code, TypeScript will now throw an error if you try to access an unknown variable.
178180

179-
180-
## Transforming Variables
181-
182-
You can also **transform** values during parsing :
183-
184-
### Built-in:
185-
186-
```ts
187-
VITE_API_URL: (key, value) => {
188-
if (!value) throw new Error(`Missing ${key}`)
189-
return value.endsWith('/') ? value : `${value}/`
190-
}
191-
```
192-
193-
### With Zod:
194-
195-
```ts
196-
VITE_API_URL: z.string().transform((v) =>
197-
v.endsWith('/') ? v : `${v}/`
198-
)
199-
```
200-
201-
See the documentation of your validator for more details.
202-
203181
## 💖 Sponsors
204182

205183
If you find this useful, consider [sponsoring me](https://github.com/sponsors/Julien-R44)! It helps support and maintain the project 🙏

0 commit comments

Comments
 (0)