Fatima Logofatima
Schemas

zod

"TypeScript-first schema validation with static type inference"

Dependencies

npm install zod
pnpm add zod
yarn add zod

Importing the schema

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 } from "fatima";
import { z, ZodType } from "zod";
import { EnvKeys } from "env";

type Constraint = Partial<Record<EnvKeys, ZodType>>

const schema = z.object<Constraint>({
  NODE_ENV: z.enum(["development", "production", "test"]),
  TZ: z.string()
});

export default config({
  schema
});

Validate

To validate, just run the validate command:

npm fatima validate
pnpm fatima validate
yarn fatima validate