Typesafe config validated by Zod
npm install zodified-configTypesafe config validated by Zod 🎉
You can install zodified-config from NPM using your prefered package manage.
For npm you can install as follows:
```
npm i zodified-config
To use zodified-config, please follow the 3 steps explained below:
ts
// src/schema.ts
import z from 'zod';export const configSchema = z.object({
value: z.string()
});
export type Config = z.infer;
`$3
`ts
// src/index.ts
import config from 'zodified-config'
import type { Config } from './schema'declare module 'zodified-config' {
interface ValidatedConfig extends Config {}
}
try {
zodifiedConfig.validate(invalidSchema);
} catch (error: unknown) {
// if you enter here, it means the config is invalid or something else went wrong
// check the error.message
}
`$3
`ts
// file other.ts
import config from 'zodified-config'config.get('value');
``