Skip to content

Commit

Permalink
mod an example that is not correct (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhythm committed May 20, 2022
1 parent 7836900 commit b57a25c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -1370,8 +1370,11 @@ stringSchema.parse(12); // throws Error('Non-string type: number');
If you use asynchronous [refinements](#refine) or [transforms](#transform) (more on those later), you'll need to use `.parseAsync`

```ts
const stringSchema = z.string().refine(async (val) => val.length > 20);
const value = await stringSchema.parseAsync("hello"); // => hello
const stringSchema1 = z.string().refine(async (val) => val.length < 20);
const value1 = await stringSchema.parseAsync("hello"); // => hello

const stringSchema2 = z.string().refine(async (val) => val.length > 20);
const value2 = await stringSchema.parseAsync("hello"); // => throws
```

### `.safeParse`
Expand Down

0 comments on commit b57a25c

Please sign in to comment.