From be330d2364669d1b71cc6a16fd9b782dc3d3e164 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Sat, 31 Jul 2021 22:22:06 -0400 Subject: [PATCH] Update changelog --- CHANGELOG.md | 4 +++- deno/lib/playground.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 deno/lib/playground.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9420eb2ac..2509e2c4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Changelog -### 4.0 +### 3.6 +- Add IE11 support +- `ZodError.flatten` now optionally accepts a map function for customizing the output - `.void()` now only accepts undefined, not null. ### 3.5 diff --git a/deno/lib/playground.ts b/deno/lib/playground.ts new file mode 100644 index 000000000..b784f97c6 --- /dev/null +++ b/deno/lib/playground.ts @@ -0,0 +1,33 @@ +import { z } from "./index.ts"; + +const run = async () => { + z; + + const propertySchema = z.string(); + const schema = z + .object({ + a: propertySchema, + b: propertySchema, + }) + .refine( + (val) => { + return val.a === val.b; + }, + { message: "Must be equal" } + ); + + try { + schema.parse({ + a: "asdf", + b: "qwer", + }); + } catch (error) { + if (error instanceof z.ZodError) { + console.log(error); + console.log(error.flatten((iss) => iss.code)); + } + } +}; +run(); + +export {};