Zum Inhalt springen
verdict:

Zod 4.2.0

notable

note: die Zusammenfassung und die Release Notes sind auf Englisch

note: keine Zusammenfassung für dieses ältere Release

Wir fassen die neueren Releases zusammen. Die originalen Release Notes dieser Version stehen hier unten.

release-notesgithub.com/colinhacks/zod · 44 Zeilen
  1. ## Features
  2. ### Implement Standard JSON Schema
  3. https://github.com/standard-schema/standard-schema/pull/134
  4. ### Implement `z.fromJSONSchema()`
  5. ```typescript
  6. const jsonSchema = {
  7. type: "object",
  8. properties: {
  9. name: { type: "string" },
  10. age: { type: "number" }
  11. },
  12. required: ["name"]
  13. };
  14. const schema = z.fromJSONSchema(jsonSchema);
  15. ```
  16. ### Implement `z.xor()`
  17. ```typescript
  18. const schema = z.xor(
  19. z.object({ type: "user", name: z.string() }),
  20. z.object({ type: "admin", role: z.string() })
  21. );
  22. // Exactly one of the schemas must match
  23. ```
  24. ### Implement `z.looseRecord()`
  25. ```typescript
  26. const schema = z.looseRecord(z.string(), z.number());
  27. // Allows additional properties beyond those defined
  28. ```
  29. ## Commits:
  30. - af49c084f66339110d00e37ff71dc7b3b9f2b7ef Update docs for JSON Schema conversion of `z.undefined()` (#5504)
  31. - 767f320318986e422f524b939f1a7174544fda2e Add `.toJSONSchema()` method (#5477)
  32. - e17dcb63573397063e87d7c7fe10a5a78968181a Add `z.fromJSONSchema()`, `z.looseRecord()`, `z.xor()` (#5534)

auf github ansehenimported 2026-09-28 über npm