Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Mar 4, 2023
1 parent 5463593 commit 8074523
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -602,6 +602,7 @@ z.string().trim(); // trim whitespace
z.string().datetime(); // defaults to UTC, see below for options
z.string().ip(); // defaults to IPv4 and IPv6, see below for options
```

<!-- z.string().toLowerCase(); // toLowerCase -->
<!-- z.string().toUpperCase(); // toUpperCase -->

Expand Down Expand Up @@ -1758,7 +1759,7 @@ This returns a `ZodEffects` instance. `ZodEffects` is a wrapper class that conta
You can create a Zod schema for any TypeScript type by using `z.custom()`. This is useful for creating schemas for types that are not supported by Zod out of the box, such as template string literals.

```ts
const px = z.custom<`${number}px`>((val) => /^\d+px$/.test(val));
const px = z.custom<`${number}px`>((val) => /^\d+px$/.test(val as string));
px.parse("100px"); // pass
px.parse("100vw"); // fail
```
Expand Down
3 changes: 2 additions & 1 deletion deno/lib/README.md
Expand Up @@ -602,6 +602,7 @@ z.string().trim(); // trim whitespace
z.string().datetime(); // defaults to UTC, see below for options
z.string().ip(); // defaults to IPv4 and IPv6, see below for options
```

<!-- z.string().toLowerCase(); // toLowerCase -->
<!-- z.string().toUpperCase(); // toUpperCase -->

Expand Down Expand Up @@ -1758,7 +1759,7 @@ This returns a `ZodEffects` instance. `ZodEffects` is a wrapper class that conta
You can create a Zod schema for any TypeScript type by using `z.custom()`. This is useful for creating schemas for types that are not supported by Zod out of the box, such as template string literals.

```ts
const px = z.custom<`${number}px`>((val) => /^\d+px$/.test(val));
const px = z.custom<`${number}px`>((val) => /^\d+px$/.test(val as string));
px.parse("100px"); // pass
px.parse("100vw"); // fail
```
Expand Down
15 changes: 3 additions & 12 deletions playground.ts
@@ -1,13 +1,4 @@
import { z } from "./src";
const baseCategorySchema = z.object({
// - name: z.string(),
name: z.string().brand("CategoryName"),
});

type Category = z.infer<typeof baseCategorySchema> & {
subcategories: Category[];
};

const categorySchema: z.ZodType<Category> = baseCategorySchema.extend({
subcategories: z.lazy(() => categorySchema.array()),
});
const px = z.custom<`${number}px`>((val) => /^\d+px$/.test(val as string));
px.parse("100px"); // pass
px.parse("100vw"); // fail

0 comments on commit 8074523

Please sign in to comment.