From 60a21346086d32ca9f39efc2771f5db37c835c03 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Fri, 19 May 2023 10:56:15 -0700 Subject: [PATCH] Add masterborn --- README.md | 123 +++++++++++++++++++++++++++------------------ deno/lib/README.md | 121 +++++++++++++++++++++++++++----------------- playground.ts | 10 ++++ 3 files changed, 159 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 9c10569c4..6e658c473 100644 --- a/README.md +++ b/README.md @@ -45,20 +45,32 @@ #### Go to [zod.js.org](https://zod.js.org) >> --> +- [Table of contents](#table-of-contents) - [Introduction](#introduction) - [Sponsors](#sponsors) + - [Gold](#gold) + - [Silver](#silver) + - [Bronze](#bronze) - [Ecosystem](#ecosystem) + - [Resources](#resources) + - [API libraries](#api-libraries) + - [Form integrations](#form-integrations) + - [Zod to X](#zod-to-x) + - [X to Zod](#x-to-zod) + - [Mocking](#mocking) + - [Powered by Zod](#powered-by-zod) + - [Utilities for Zod](#utilities-for-zod) - [Installation](#installation) - [Requirements](#requirements) - - [Node/npm](#from-npm-nodebun) - - [Deno](#from-denolandx-deno) + - [From `npm` (Node/Bun)](#from-npm-nodebun) + - [From `deno.land/x` (Deno)](#from-denolandx-deno) - [Basic usage](#basic-usage) - [Primitives](#primitives) - [Coercion for primitives](#coercion-for-primitives) - [Literals](#literals) - [Strings](#strings) - - [Datetime](#iso-datetimes) - - [IP](#ip-addresses) + - [ISO datetimes](#iso-datetimes) + - [IP addresses](#ip-addresses) - [Numbers](#numbers) - [BigInts](#bigints) - [NaNs](#nans) @@ -69,59 +81,74 @@ - [Optionals](#optionals) - [Nullables](#nullables) - [Objects](#objects) - - [.shape](#shape) - - [.keyof](#keyof) - - [.extend](#extend) - - [.merge](#merge) - - [.pick/.omit](#pickomit) - - [.partial](#partial) - - [.deepPartial](#deepPartial) - - [.passthrough](#passthrough) - - [.strict](#strict) - - [.strip](#strip) - - [.catchall](#catchall) + - [`.shape`](#shape) + - [`.keyof`](#keyof) + - [`.extend`](#extend) + - [`.merge`](#merge) + - [`.pick/.omit`](#pickomit) + - [`.partial`](#partial) + - [`.deepPartial`](#deeppartial) + - [`.required`](#required) + - [`.passthrough`](#passthrough) + - [`.strict`](#strict) + - [`.strip`](#strip) + - [`.catchall`](#catchall) - [Arrays](#arrays) - - [.element](#element) - - [.nonempty](#nonempty) - - [.min/.max/.length](#minmaxlength) + - [`.element`](#element) + - [`.nonempty`](#nonempty) + - [`.min/.max/.length`](#minmaxlength) - [Tuples](#tuples) - [Unions](#unions) -- [Discriminated Unions](#discriminated-unions) +- [Discriminated unions](#discriminated-unions) - [Records](#records) + - [Record key type](#record-key-type) - [Maps](#maps) - [Sets](#sets) - [Intersections](#intersections) - [Recursive types](#recursive-types) + - [ZodType with ZodEffects](#zodtype-with-zodeffects) - [JSON type](#json-type) - - [Cyclical data](#cyclical-objects) + - [Cyclical objects](#cyclical-objects) - [Promises](#promises) - [Instanceof](#instanceof) - [Functions](#functions) - [Preprocess](#preprocess) -- [Custom](#custom-schemas) +- [Custom schemas](#custom-schemas) - [Schema methods](#schema-methods) - - [.parse](#parse) - - [.parseAsync](#parseasync) - - [.safeParse](#safeparse) - - [.safeParseAsync](#safeparseasync) - - [.refine](#refine) - - [.superRefine](#superRefine) - - [.transform](#transform) - - [.default](#default) - - [.describe](#describe) - - [.catch](#catch) - - [.optional](#optional) - - [.nullable](#nullable) - - [.nullish](#nullish) - - [.array](#array) - - [.promise](#promise) - - [.or](#or) - - [.and](#and) - - [.brand](#brand) - - [.pipe](#pipe) + - [`.parse`](#parse) + - [`.parseAsync`](#parseasync) + - [`.safeParse`](#safeparse) + - [`.safeParseAsync`](#safeparseasync) + - [`.refine`](#refine) + - [Arguments](#arguments) + - [Customize error path](#customize-error-path) + - [Asynchronous refinements](#asynchronous-refinements) + - [Relationship to transforms](#relationship-to-transforms) + - [`.superRefine`](#superrefine) + - [Abort early](#abort-early) + - [Type refinements](#type-refinements) + - [`.transform`](#transform) + - [Chaining order](#chaining-order) + - [Validating during transform](#validating-during-transform) + - [Relationship to refinements](#relationship-to-refinements) + - [Async transforms](#async-transforms) + - [`.default`](#default) + - [`.describe`](#describe) + - [`.catch`](#catch) + - [`.optional`](#optional) + - [`.nullable`](#nullable) + - [`.nullish`](#nullish) + - [`.array`](#array) + - [`.promise`](#promise) + - [`.or`](#or) + - [`.and`](#and) + - [`.brand`](#brand) + - [`.pipe()`](#pipe) + - [You can use `.pipe()` to fix common issues with `z.coerce`.](#you-can-use-pipe-to-fix-common-issues-with-zcoerce) - [Guides and concepts](#guides-and-concepts) - [Type inference](#type-inference) - [Writing generic functions](#writing-generic-functions) + - [Constraining allowable inputs](#constraining-allowable-inputs) - [Error handling](#error-handling) - [Error formatting](#error-formatting) - [Comparison](#comparison) @@ -129,6 +156,7 @@ - [Yup](#yup) - [io-ts](#io-ts) - [Runtypes](#runtypes) + - [Ow](#ow) - [Changelog](#changelog) @@ -386,17 +414,16 @@ Sponsorship at any level is appreciated and encouraged. For individual developer ill.inc
- + @@ -462,7 +489,7 @@ There are a growing number of tools that are built atop or support Zod natively! - [`@anatine/zod-mock`](/~https://github.com/anatine/zod-plugins/tree/main/packages/zod-mock): Generate mock data from a Zod schema. Powered by [faker.js](/~https://github.com/faker-js/faker). - [`zod-mocking`](/~https://github.com/dipasqualew/zod-mocking): Generate mock data from your Zod schemas. -- [`zocker`](https://zocker.sigrist.dev): Generate plausible mock-data from your schemas. +- [`zocker`](https://zocker.sigrist.dev): Generate plausible mock-data from your schemas. #### Powered by Zod diff --git a/deno/lib/README.md b/deno/lib/README.md index 081790293..d2eb9b24c 100644 --- a/deno/lib/README.md +++ b/deno/lib/README.md @@ -45,20 +45,32 @@ #### Go to [zod.js.org](https://zod.js.org) >> --> +- [Table of contents](#table-of-contents) - [Introduction](#introduction) - [Sponsors](#sponsors) + - [Gold](#gold) + - [Silver](#silver) + - [Bronze](#bronze) - [Ecosystem](#ecosystem) + - [Resources](#resources) + - [API libraries](#api-libraries) + - [Form integrations](#form-integrations) + - [Zod to X](#zod-to-x) + - [X to Zod](#x-to-zod) + - [Mocking](#mocking) + - [Powered by Zod](#powered-by-zod) + - [Utilities for Zod](#utilities-for-zod) - [Installation](#installation) - [Requirements](#requirements) - - [Node/npm](#from-npm-nodebun) - - [Deno](#from-denolandx-deno) + - [From `npm` (Node/Bun)](#from-npm-nodebun) + - [From `deno.land/x` (Deno)](#from-denolandx-deno) - [Basic usage](#basic-usage) - [Primitives](#primitives) - [Coercion for primitives](#coercion-for-primitives) - [Literals](#literals) - [Strings](#strings) - - [Datetime](#datetime-validation) - - [IP](#ip-address-validation) + - [ISO datetimes](#iso-datetimes) + - [IP addresses](#ip-addresses) - [Numbers](#numbers) - [BigInts](#bigints) - [NaNs](#nans) @@ -69,59 +81,74 @@ - [Optionals](#optionals) - [Nullables](#nullables) - [Objects](#objects) - - [.shape](#shape) - - [.keyof](#keyof) - - [.extend](#extend) - - [.merge](#merge) - - [.pick/.omit](#pickomit) - - [.partial](#partial) - - [.deepPartial](#deepPartial) - - [.passthrough](#passthrough) - - [.strict](#strict) - - [.strip](#strip) - - [.catchall](#catchall) + - [`.shape`](#shape) + - [`.keyof`](#keyof) + - [`.extend`](#extend) + - [`.merge`](#merge) + - [`.pick/.omit`](#pickomit) + - [`.partial`](#partial) + - [`.deepPartial`](#deeppartial) + - [`.required`](#required) + - [`.passthrough`](#passthrough) + - [`.strict`](#strict) + - [`.strip`](#strip) + - [`.catchall`](#catchall) - [Arrays](#arrays) - - [.element](#element) - - [.nonempty](#nonempty) - - [.min/.max/.length](#minmaxlength) + - [`.element`](#element) + - [`.nonempty`](#nonempty) + - [`.min/.max/.length`](#minmaxlength) - [Tuples](#tuples) - [Unions](#unions) -- [Discriminated Unions](#discriminated-unions) +- [Discriminated unions](#discriminated-unions) - [Records](#records) + - [Record key type](#record-key-type) - [Maps](#maps) - [Sets](#sets) - [Intersections](#intersections) - [Recursive types](#recursive-types) + - [ZodType with ZodEffects](#zodtype-with-zodeffects) - [JSON type](#json-type) - - [Cyclical data](#cyclical-objects) + - [Cyclical objects](#cyclical-objects) - [Promises](#promises) - [Instanceof](#instanceof) - [Functions](#functions) - [Preprocess](#preprocess) -- [Custom](#custom-schemas) +- [Custom schemas](#custom-schemas) - [Schema methods](#schema-methods) - - [.parse](#parse) - - [.parseAsync](#parseasync) - - [.safeParse](#safeparse) - - [.safeParseAsync](#safeparseasync) - - [.refine](#refine) - - [.superRefine](#superRefine) - - [.transform](#transform) - - [.default](#default) - - [.describe](#describe) - - [.catch](#catch) - - [.optional](#optional) - - [.nullable](#nullable) - - [.nullish](#nullish) - - [.array](#array) - - [.promise](#promise) - - [.or](#or) - - [.and](#and) - - [.brand](#brand) - - [.pipe](#pipe) + - [`.parse`](#parse) + - [`.parseAsync`](#parseasync) + - [`.safeParse`](#safeparse) + - [`.safeParseAsync`](#safeparseasync) + - [`.refine`](#refine) + - [Arguments](#arguments) + - [Customize error path](#customize-error-path) + - [Asynchronous refinements](#asynchronous-refinements) + - [Relationship to transforms](#relationship-to-transforms) + - [`.superRefine`](#superrefine) + - [Abort early](#abort-early) + - [Type refinements](#type-refinements) + - [`.transform`](#transform) + - [Chaining order](#chaining-order) + - [Validating during transform](#validating-during-transform) + - [Relationship to refinements](#relationship-to-refinements) + - [Async transforms](#async-transforms) + - [`.default`](#default) + - [`.describe`](#describe) + - [`.catch`](#catch) + - [`.optional`](#optional) + - [`.nullable`](#nullable) + - [`.nullish`](#nullish) + - [`.array`](#array) + - [`.promise`](#promise) + - [`.or`](#or) + - [`.and`](#and) + - [`.brand`](#brand) + - [`.pipe()`](#pipe) + - [You can use `.pipe()` to fix common issues with `z.coerce`.](#you-can-use-pipe-to-fix-common-issues-with-zcoerce) - [Guides and concepts](#guides-and-concepts) - [Type inference](#type-inference) - [Writing generic functions](#writing-generic-functions) + - [Constraining allowable inputs](#constraining-allowable-inputs) - [Error handling](#error-handling) - [Error formatting](#error-formatting) - [Comparison](#comparison) @@ -129,6 +156,7 @@ - [Yup](#yup) - [io-ts](#io-ts) - [Runtypes](#runtypes) + - [Ow](#ow) - [Changelog](#changelog) @@ -386,17 +414,16 @@ Sponsorship at any level is appreciated and encouraged. For individual developer ill.inc
- + diff --git a/playground.ts b/playground.ts index 8f4b672ca..a135d7707 100644 --- a/playground.ts +++ b/playground.ts @@ -1,12 +1,22 @@ import { z } from "./src"; z; +console.log( + z + .string() + .toUpperCase() + .pipe(z.enum(["DE", "EN"])) + .parse("de") +); + function recursive( callback: (schema: G) => T ): T { return "asdf" as any; } +z.string(); + const cat = recursive((type) => { return z.object({ name: z.string(),