From 2db0dcadc961fd57f7f10f9d9f55d67e6d040342 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Mon, 6 Mar 2023 13:46:06 -0800 Subject: [PATCH] 3.21.3 --- package.json | 2 +- playground.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e57bdae93..9a44f634a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zod", - "version": "3.21.2", + "version": "3.21.3", "author": "Colin McDonnell ", "repository": { "type": "git", diff --git a/playground.ts b/playground.ts index d17b18eb4..b22662a96 100644 --- a/playground.ts +++ b/playground.ts @@ -1,2 +1,18 @@ import { z } from "./src"; z; + +const baseCategorySchema = z.object({ + name: z.string().brand("CategoryName"), +}); + +type CategoryInput = z.input & { + subcategories: CategoryInput[]; +}; +type CategoryOutput = z.output & { + subcategories: CategoryOutput[]; +}; + +const categorySchema: z.ZodType = + baseCategorySchema.extend({ + subcategories: z.lazy(() => categorySchema.array()), + });