Skip to content

Commit

Permalink
Merge pull request #745 from mmvsk/master
Browse files Browse the repository at this point in the history
Fix documentation for ZodArray .element (issue #744)
  • Loading branch information
colinhacks authored Nov 4, 2021
2 parents fdd7084 + 6857f56 commit f4cd16d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This docs have been translated into [Chinese](./README_ZH.md).
- [.strip](#strip)
- [.catchall](#catchall)
- [Arrays](#arrays)
- [.element](#element)
- [.nonempty](#nonempty)
- [.min/.max/.length](#minmaxlength)
- [Tuples](#tuples)
Expand Down Expand Up @@ -814,6 +815,14 @@ z.string().optional().array(); // (string | undefined)[]
z.string().array().optional(); // string[] | undefined
```

### `.element`

Use `.element` to access the schema for an element of the array.

```ts
stringArray.element; // => string schema
```

### `.nonempty`

If you want to ensure that an array contains at least one element, use `.nonempty()`.
Expand Down

0 comments on commit f4cd16d

Please sign in to comment.