note: la synthèse et les notes de version sont en anglais
note: pas de synthèse pour cette release plus ancienne
Nous synthétisons les releases récentes. Les notes de version originales de cette version sont ci-dessous.
release-notesgithub.com/colinhacks/zod · 44 lignes
- ## Features
- ### Implement Standard JSON Schema
- https://github.com/standard-schema/standard-schema/pull/134
- ### Implement `z.fromJSONSchema()`
- ```typescript
- const jsonSchema = {
- type: "object",
- properties: {
- name: { type: "string" },
- age: { type: "number" }
- },
- required: ["name"]
- };
- const schema = z.fromJSONSchema(jsonSchema);
- ```
- ### Implement `z.xor()`
- ```typescript
- const schema = z.xor(
- z.object({ type: "user", name: z.string() }),
- z.object({ type: "admin", role: z.string() })
- );
- // Exactly one of the schemas must match
- ```
- ### Implement `z.looseRecord()`
- ```typescript
- const schema = z.looseRecord(z.string(), z.number());
- // Allows additional properties beyond those defined
- ```
- ## Commits:
- - af49c084f66339110d00e37ff71dc7b3b9f2b7ef Update docs for JSON Schema conversion of `z.undefined()` (#5504)
- - 767f320318986e422f524b939f1a7174544fda2e Add `.toJSONSchema()` method (#5477)
- - e17dcb63573397063e87d7c7fe10a5a78968181a Add `z.fromJSONSchema()`, `z.looseRecord()`, `z.xor()` (#5534)