From c0f6f62c71343da5e3c542e45f540fb8c1ff3263 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Sat, 31 Jul 2021 21:57:54 -0400 Subject: [PATCH] Add ie11 message --- README.md | 2 +- deno/lib/playground.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 deno/lib/playground.ts diff --git a/README.md b/README.md index c7513e0e5..56cfe7042 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Zod is designed to be as developer-friendly as possible. The goal is to eliminat Some other great aspects: - Zero dependencies -- Works in browsers and Node.js +- Works in Node.js and browsers (including IE 11) - Tiny: 8kb minified + zipped - Immutable: methods (i.e. `.optional()` return a new instance - Concise, chainable interface 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 {};