Skip to content

Commit

Permalink
fix: add changeset with example
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalics committed Sep 13, 2024
1 parent 1a0f989 commit 57bff56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .changeset/flat-rice-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"ajv-ts": minor
---

Add `example` for every schema.

Example:

```ts
s.string().examples(["str1", 'string 2']) // OK
s.number().examples(["str1", 'string 2']) // Error in typescript, but OK
s.number().examples([1, 2, 3]) // OK
s.number().examples(1, 2, 3) // OK
```
2 changes: 1 addition & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class SchemaBuilder<
* @see {@link https://www.learnjsonschema.com/2020-12/meta-data/examples JSON-schema examples definition}
* @example
* s.string().examples(["str1", 'string 2']) // OK
* s.number().examples(["str1", 'string 2']) // Error
* s.number().examples(["str1", 'string 2']) // Error in Typescript, schema is OK
* s.number().examples([1, 2, 3]) // OK
* s.number().examples(1, 2, 3) // OK
*/
Expand Down

0 comments on commit 57bff56

Please sign in to comment.