Zod Validation
Zod Validation
You can now use Zod as a validation library, in cases where you need a stricter validation or if you just prefer it.
// env.ts
export default defineConfig({
validator: 'zod',
schema: {
VITE_MY_STRING: z.string().min(5, 'This is too short !').startWith('h').endsWith('/'),
VITE_ENUM: z.enum(['a', 'b', 'c']),
VITE_AUTH_API_URL: z
.string()
.transform((value) => value.endsWith('/') ? value : `${value}/`),
}
})Less verbose import.meta.env typing
Just made a little helper for getting the correct IntelliSense on import.meta.env. Can be used as follows:
type ImportMetaEnvAugmented = import('@julr/vite-plugin-validate-env').ImportMetaEnvAugmented<typeof import('../env').default>
interface ImportMetaEnv extends ImportMetaEnvAugmented {}