Fatima Logofatima

zod

"TypeScript-first schema validation with static type inference"

Dependencies

npm install zod

Importing the validator

Generate your types

If you generate your types before writing validation, they will be available to help you define the constraint.

env.config.ts
import { config, validators } from "fatima";
import { z, ZodType } from "zod";
import { EnvRecord } from "env";
 
type Constraint = Partial<EnvRecord<ZodType>>;
 
const schema = z.object<Constraint>({
  NODE_ENV: z.string().email()
  TZ: z.string()
});
 
export default config({
  validate: validators.zod(schema),
});

Validate

To validate, just run the validate command:

npm fatima validate

On this page