Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 622 Bytes

README.md

File metadata and controls

20 lines (17 loc) · 622 Bytes

Get and validate AWS CDK context against Zod schema. Get typed, validated context as a result, or error will be thrown.

import { getValidatedContext, z } from 'zod-cdk-context'

// {
//   foo: string;
//   bar?: string;
//   baz: number;
//   env: "prd" | "dev"
// }
const { foo, bar, baz, env } = getValidatedContext(app.node, {
  foo: z.string().min(1),
  bar: z.string().min(1).optional(),
  baz: z.coerce.number(),
  env: z.enum(['prd', 'dev']),
})

Article with some implementation details