Skip to content

Conversation

@RobinTail
Copy link
Contributor

@RobinTail RobinTail commented Apr 18, 2025

The default range (min/max representable numbers) is inclusive, not exclusive.

Addressing the bug I found and previously described in #4074 (comment)

Summary by CodeRabbit

  • Bug Fixes

    • Updated numeric type schemas to use inclusive bounds (maximum and minimum) instead of exclusive bounds in JSON Schema output.
  • Tests

    • Updated test snapshots to reflect the use of inclusive numeric boundaries in schema conversion.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

Walkthrough

This update introduces an inclusive property set to true in the computed object of $ZodCheckNumberFormat during its onattach lifecycle. Additionally, the JSON Schema test snapshots for numeric types are updated to use maximum and minimum properties instead of exclusiveMaximum and exclusiveMinimum, reflecting a shift from exclusive to inclusive numeric bounds. No changes were made to exported or public entity declarations, and the overall logic remains consistent.

Changes

Files/Paths Change Summary
packages/core/src/checks.ts Added inclusive: true to the computed object for $ZodCheckNumberFormat during onattach.
packages/zod/tests/json-schema.test.ts Updated test snapshots: replaced exclusiveMaximum/exclusiveMinimum with maximum/minimum.

Poem

Inclusive bounds, a gentler tone,
Numbers now feel right at home.
Snapshots shift, the tests agree,
Maximum and minimum, as clear as can be.
With every check, we’re feeling fine—
Here’s to code that draws the line!
🎉🔢

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6ab10d and c46027b.

📒 Files selected for processing (2)
  • packages/core/src/checks.ts (1 hunks)
  • packages/zod/tests/json-schema.test.ts (1 hunks)
🔇 Additional comments (5)
packages/core/src/checks.ts (1)

274-274: Nice addition of the inclusive property 👍

Setting inclusive to true in the computed object correctly implements the fix to make the default numeric range inclusive instead of exclusive. This change aligns perfectly with the PR objective and ensures that the min/max values are treated as part of the valid range.

packages/zod/tests/json-schema.test.ts (4)

160-162: Test snapshot update looks good

Changing from exclusiveMaximum/exclusiveMinimum to maximum/minimum in the test snapshot properly reflects the switch to inclusive numeric bounds for integers. This matches the implementation change and ensures tests will pass with the new behavior.


167-169: Consistent change for int32 bounds

The change to use maximum/minimum instead of exclusive variants maintains consistency with the new inclusive boundary behavior. This looks good!


174-176: Float32 bounds updated correctly

The snapshot update for float32 follows the same pattern, switching to inclusive boundaries. The max/min values remain unchanged, just the property names are updated to reflect the new inclusive behavior.


181-183: Float64 bounds properly updated

Same consistent change applied to float64 type. All numeric type tests now properly expect inclusive boundaries instead of exclusive ones, which matches the implementation change in the core package.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@RobinTail
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@RobinTail RobinTail mentioned this pull request Apr 18, 2025
@RobinTail
Copy link
Contributor Author

@colinhacks , I believe it's an important fix.

@RobinTail RobinTail changed the title Correcting the default numeric range to be inclusive v4: Correcting the default numeric range to be inclusive Apr 20, 2025
RobinTail added a commit to RobinTail/express-zod-api that referenced this pull request Apr 20, 2025
Exploring the possibility to delegate OpenAPI compatible depiction to
JSON Schema based method of Zod 4.

Current issues:
- Can not depict `BigInt` with throwing error if it's within
`ZodLiteral`
  - colinhacks/zod#4220 
- Numeric limits are wrong:
  - exclusive, while should be inclusive
  - missing at all (`z.number().int().positive()`)
  - colinhacks/zod#4074 (comment)
  - suggested fix colinhacks/zod#4224
- Overrides act after default depiction, not before, so that much has to
be rewritten
@colinhacks colinhacks merged commit e2ef2aa into colinhacks:v4 Apr 21, 2025
4 checks passed
@colinhacks
Copy link
Owner

Wonderful stuff, thanks Anna!

colinhacks added a commit that referenced this pull request May 19, 2025
* feat(lang): Added initial Azerbaijani locale (#4158)

* feat(lang): Added initial Azerbaijani locale

* Format

---------

Co-authored-by: Colin McDonnell <[email protected]>

* fix(docs): Typo fro (#4157)

* Fix broken logo link (#3974)

* Fix broken logo link

* Use absolute URL

* Absolute url

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Add packages/docs

* Remove packages/docs

* Clean up zodmini exports with underscores

* Add precommit format

* Fix error generic

* Fix optionality docs

* tweak (#4173)

Co-authored-by: Colin McDonnell <[email protected]>

* fix: dev:play script to use play.ts instead of playground.ts (#4177)

* Optimize `extendShape` (#4150)

Co-authored-by: Anders Hejlsberg <[email protected]>

* 3.24.3

* add back packages/docs

* Update

* Update benchmark

* Refactor `Extend` to preserve declaration links (#4155)

* Refactor `ExtendShape` to preserve declaration links

* fix type issues

* Simplify aliases

* Fix lint

* Fix

* Update benchmarks

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Fix en.ts

* 0.5.2

* 0.6.0

* Fix enum type portability

* Clean up passthrough schemas in toJSONSchema

* 0.6.3

* v4: fix typos in basics guide (#4211)

- Removed redundant whitespaces before `string()` method
- Fixed typo in the note to `.parse()` method

* v4: fix typo in defining schemas section (#4219)

* fix migration guide typos (#4205)

* partial record

* Clean up toJSONSchema behavior. extract schemas with ids

* Improve core.mdx

* Fix missing methods

* 0.7.0

* Fix unrepresentable literals and onattach issues

* 0.8.0

* Improve error customization docs

* Clarify error docs

* Closes #4089

* Fix starts_with

* docs: add zod-schema-faker to ecosystem (#4247)

* fix(docs): Correct "with with" typo. (#4243)

Correct "with with" typo.

* fix(docs): Correct typo in Records (#4244)

Correct typo in Records "that as" instead of "that is".

* fix(docs): Typo in `z.object()` vs `z.interface()` (#4241)

Update documentation to clarify that optional properties in
`z.interface()` are defined with a `?` suffix, not a prefix.

* Correcting the default numeric range to be inclusive. (#4224)

* Reusing `Number.MAX_VALUE` for `float64` range (#4222)

* Clarify defaults for `toJsonSchema` options (#4223)

* docs: add GQLoom to ecosystem (#4225)

* fix(docs): Swap Enum `.exclude() / .extract()` code samples. (#4242)

The code samples in `.exclude()` belong to `.extract()` and vice versa.

* fix(docs): Grammatical error in Refinements (#4252)

Correct grammatical error in Refinements

* Improve handling of `.meta()`/`.describe()` in JSON Schema converter (#4255)

* WIP

* Big improvements to meta and describe handling

* WIP

* Lazy disc

* Add cybozu

* 0.9.0

* Feature Stainless

* Edit alt text

* doc: fixed missing comment in migration guide (#4293)

* fix migration guide typo (#4291)

* Add "zod-config" to ecosystem.tsx (v4 support via pre-release) (#4282)

* Update ecosystem.tsx to add "zod-config" with v4 support via RC

* fix(docs): Correct formatting in ecosystem.tsx for "zod-config" entry

---------

Co-authored-by: Alexandre Marques <[email protected]>

* docs: add support for `kubb` as part of the v4 upgrade (#4260)

* Add methods to string formats (#4296)

* 0.10.0

* Tweak

* Tweak

* z._default

* Correct conditions for error in docs (#4312)

- Make schema a strict object
- Add extra key to induce error described later

* fix vscode debug issue with tsx runtime (#4306)

* Tweak default docs

* correction in documentation (#4303)

(zod example using @zod/mini import)

* WIP

* Make ulid case insensitive

* v0.10.1

* Improve jsdoc

* ULID

* docs: in v4, `strict()` is not deprecated (#4298)

* docs: in v4, `strict()` is not deprecated

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* chore: add `orval` to XtoZod ecosystems in v4 (#4256)

Co-authored-by: Colin McDonnell <[email protected]>

* Add composable-functions as a library powered by Zod supporting v4 (#4261)

* Add composable-functions as a library powered by Zod supporting v4

* docs: in v4, `strict()` is not deprecated (#4298)

* docs: in v4, `strict()` is not deprecated

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* chore: add `orval` to XtoZod ecosystems in v4 (#4256)

Co-authored-by: Colin McDonnell <[email protected]>

---------

Co-authored-by: Shodai Suzuki <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>

* Support recursive types in `z.object()`, drop `z..interface()` (#4271)

* WIP

* WIP

* Add qin

* WIP

* Refactor object-like internals. use optionality in zodinterface shape. remove ?-prefixing for defaulted. handle optionals/defaults in json schema

* WIP

* WIP

* Generics are working

* WIP

* WIP

* Fix

* Fix tests

* Fix tests

* WIP

* WIP

* Drop `z.interface()` from docs (#4316)

* Drop interface

* Format

* Feature

* Allow HH:MM format in `z.string().datetime()` and `z.string().time()` (#4315)

* feat: allow omitting seconds in time string

* docs: include examples of omitted seconds

* docs: remove whitespace

* 3.23.4

* V4(fix): generate json-schema with min/max(0) (#4267)

* fix: generate number json schema

* fix: generate json schema with min/max(0)

* Apply suggestions from code review

fix: format

Co-authored-by: Anna Bocharova <[email protected]>

---------

Co-authored-by: Panda <[email protected]>
Co-authored-by: Anna Bocharova <[email protected]>

* 0.11.1

* docs: added @regle/schemas to form ecosystem (#4169)

* docs: added @regle/schemas to form ecosystem

In my previous MR you said to edit `components/ecosystem.mdx` but couldn't find it, if it was a typo i guessed it was this file! 👍

* Add to ecosystem.tsx

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Fix union inferred type issue

* v0.11.2

* optionalObjectKeys -> optionalKeys

* 0.11.3

* Add test for union types

* Fix assignability

* 0.11.4

* Add assignability tests

* Stack trace in parse and parseAsync

* Biome

* Clean up code, fix lock

* Document default changes

* Clarify deprecations

* Update changelog

* v0.11.6. support recursive types in zodmini

* Add recursive type tests for zod mini

* Add recursive tests for zod mini

* fix(core): use `Object.create(null)` to cache ids (#4359)

* Jazz sponsorship

* Update Speakeasy sponsor URL (#4337)

* fix: use input, not output, for input of ZodUnionInternals (#4330)

* Languages: Add Japanese language (#4170)

* Add Japanese locale

* format

* fix(ja): Fixed comparison operator in error messages

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* New parse signature

* Fix parse functions

* Add Jazz

* Languages: Add Portuguese language (#4171)

* Adding portuguese translations

* Adding portuguese

* Adding language to docs

* Adding spanish language in docs

* Tweak

* Updating references from string to texto

* Updating faixa to faixa de

* Updating from elementos to itens

* Mirroring validation from original file

* Updating regex to padrao

* Updating entrada by tipo

* Replacing entrada by campo

---------

Co-authored-by: Helmer <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>

* Languages: Add french language (#4172)

* Adding french and exporting it

* Adding french in docs

* Update fr.ts

Co-authored-by: Florian Lefebvre <[email protected]>

* Translating datetime

* Tweak

* Update elements

* Update packages/core/src/locales/fr.ts

Co-authored-by: Fabrice Cipolla <[email protected]>

---------

Co-authored-by: Helmer <[email protected]>
Co-authored-by: Florian Lefebvre <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>
Co-authored-by: Fabrice Cipolla <[email protected]>

* Languages: Add Arabic language (#4176)

* feat(lang): Add Arabic locale support

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* remove period

* fix: add space after comparison operator

* feat(lang): Add Arabic locale support

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* Update packages/core/src/locales/ar.ts

Co-authored-by: Abdullah Mohammed <[email protected]>

* remove period

* fix: add space after comparison operator

* Tweak

* Updated ar.ts with new edits discussed in #4176

* Update packages/core/src/locales/ar.ts

* Update packages/core/src/locales/ar.ts

* Update packages/core/src/locales/ar.ts

* chore: format

* fix: update translation for template_literal

* fix: correct translation for invalid input error message

* fix: spacing in error messages

* fix: show correct prefix

* fix: remove unused template literal

* Update error-customization.mdx

---------

Co-authored-by: Abdullah Mohammed <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>
Co-authored-by: Hosam Hamdy <[email protected]>

* Languages: Add Hebrew language (#4183)

* Create he.ts

* Update locales.ts

* Update error-customization.mdx

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add Polish 🇵🇱 language (#4184)

* Languages: add polish language

* Fix: apply formatting

* Tweak

* Fix: add missing fallbacks

* Update packages/core/src/locales/pl.ts

Co-authored-by: Marcel <[email protected]>

* Update packages/core/src/locales/pl.ts

Co-authored-by: Marcel <[email protected]>

---------

Co-authored-by: Colin McDonnell <[email protected]>
Co-authored-by: Marcel <[email protected]>

* Languages: add Ukrainian language (#4185)

* locale: add ukrainian language

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add Finnish language (#4188)

* feat: add initial finnish translations

* chore: add export and docs

* Tweak

* feat: add more translations for different data types

* fix: lint errors

* fix: map translation

* feat: only handle used cases in TypeNames

* refactor: pr comments

* refactor: map translation

* refactor: heavily simplify finnish translations

* chore: use unioni instead of yhdiste

Might be more commonly used (gut feeling).

* style: remove unused imports

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add Hungarian language (#4186)

* add hungarian

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Add Simplified Chinese (#4189)

* feat(lang): add Simplified Chinese

* fix: locale

* fix: space format

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(lang): add Vietnamese (vi) locale (#4191)

* feat(lang): add Vietnamese (vi) locale

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add Czech language 🇨🇿 (#4192)

* feat: add czech error locales

* fix(locales): improve Czech error messages for clarity

* Fmt

* fix(locales): use correct string error prefix in error message

For Czech language.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix(locales): translate other data types as well

For Czech language.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix(locales): handle nullable variables in error messages

For Czech langauge.

---------

Co-authored-by: Colin McDonnell <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Languages: add italian language (#4194)

* feat: added italian language

* Fmt

* Tweak

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add Indonesia language (#4195)

* Languages: add Bahasa Indonesia language

* tweak

* Tweak

* Update packages/core/src/locales/id.ts

Co-authored-by: Griko Nibras <[email protected]>

* Update packages/core/src/locales/id.ts

Co-authored-by: Griko Nibras <[email protected]>

* Update packages/core/src/locales/id.ts

Co-authored-by: Griko Nibras <[email protected]>

* Update packages/core/src/locales/id.ts

Co-authored-by: Griko Nibras <[email protected]>

* Update packages/core/src/locales/id.ts

Co-authored-by: Griko Nibras <[email protected]>

---------

Co-authored-by: Colin McDonnell <[email protected]>
Co-authored-by: Griko Nibras <[email protected]>

* feat(lang): Added initial Turkish locale (#4196)

* feat(lang): Added initial Turkish locale

* fix(lang): Improve formatting in Turkish error messages

* fix(lang): Update Turkish translations for various terms

* fix(lang): Update Turkish translations for base64 and template literal terms

* fix(lang): Correct Turkish error message for 'starts_with' format

* test(lang): Add unit tests for Turkish locale parsing and validation

* test(lang): Remove console log from Turkish locale test for cleaner output

Co-authored-by: Mert Şişmanoğlu <[email protected]>

* fix(lang): Correct variable reference in Turkish 'starts_with' error message

Co-authored-by: Mert Şişmanoğlu <[email protected]>

---------

Co-authored-by: Mert Şişmanoğlu <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): add russian language (#4197)

* feat(locale): add russian language

* updates

* feat(locale): add Russian pluralization rules

* fix: tests

* fixes

* fix(locale): correct error message for string format validation in Russian locale

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): add belarusian language (#4199)

* feat(locale): add belarusian language

* feat: add belarusian plurals support

* fix(locale): correct Belarusian error message formatting for string validation

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(lang): Add ota locale in Latin script (#4200)

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: Add Korean language (#4206)

* chore: run format

* feat(locale): add Korean language

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: Add Farsi language (#4207)

* feat(lang): add farsi language

* fix: joinValues in invalid_value

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): Add Urdu language (#4208)

* feat(locale): add urdu language

* Fix formatting for ur.ts file

* Fix formatting for ur.ts file

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Add Macedonian locale support and update documentation (#4214)

Co-authored-by: Antonio Ivanovski <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>

* Add-fr-ca-locale (#4218)

* chore: Add .pnpm-store to .gitignore

* chore: Add Canadian French locale support

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): add Traditional Chinese (#4226)

* feat(locale): add Traditional Chinese

* fix

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): Add Norwegian (#4229)

* feat: added Norwegian (Bokmål)

* fix: renamed locale to no + improved translations

* fix: forgot to add the file to git...

* fix: more accurate verb for collections

* chore: removed commented out code

* chore: ran linter

* fix: minor tweaks to error messages

* Update packages/core/src/locales/no.ts

I agree, that's better!

Co-authored-by: Steffen Holanger <[email protected]>

---------

Co-authored-by: Magne Skutle <[email protected]>
Co-authored-by: Steffen Holanger <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>

* feat(lang): Added initial Thai locale (#4230)

* feat(lang): Added initial Thai locale

* fix(lang): improve thai translation for clarify meaning

---------

Co-authored-by: Colin McDonnell <[email protected]>

* feat(locale): Add SL locale (#4231)

Co-authored-by: Colin McDonnell <[email protected]>

* feat(lang): Added initial `Tamil` locale (#4237)

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: add German language (#4253)

* feat(locales): add Catalan locale support and update documentation (#4287)

Co-authored-by: Colin McDonnell <[email protected]>

* Languages: Add Malay language (#4204)

* feat(lang): add Malay support

* chore: run format

---------

Co-authored-by: Colin McDonnell <[email protected]>

* Fix issue issue

* Subclass Error

* Update Error inheritance

* Clean up Error inheritance

* Fix prom test

* Refactor: add subpath imports `zod/v4` (#4364)

* Refactor to subpaths

* Tweak

* Roll back to tshy 1

* Use supershy

* Lint

* drop dryrun

* Add root re-export

* Add file

* Update docs

* Update guide

* Docs and locales barrel file

* Update announcement and changelog

* Update anno

* Add accordion

* Fix readonly issue on zodminienum. Rename _getter to innerType on zodlazy

* Fix diagonal enum issue

* Improve `z.url()`: support `hostname` and `protocol` regexes (#4367)

* Improve z.url(). Add support for hostname and protocol regexes

* Add docs

* Add z.core.$ZodBranded

* Add jitless config flag (#4368)

* Remove util.Exactly from zod-mini masks

* Roll back never toJSONSchema

* Update snaps

* v4: set additionalProperties to false when catchall is never (#4365)

* Document dropping of ctx.path in changelog

* Remove z.core from zod/v4-mini

* Add back z.core

* Document .refine overload drop

* Fix input type for ZodMiniDate

* Add zodpipe mini test

* Clean up params

* Fix test

* docs: escape `.` in the example regex for `z.url` with `hostname` (#4375)

* Document moduleResolution

* typo

* Implement `z.prefault` (#4376)

* WIP

* Implement prefault

* Document prefault

* Add link to function workaround

* Defer initialization to avoid crashes with z.lazy. Closes #4324. (#4377)

* noPrecompilation -> jitless

* Update ZodError section in changelog. Deprecate isOptional and isNullable

* Return data on best-effort basis despite errors

* Fix prefixIssues issue

* Add fallback File interface

* Add back formatError and flattenError functions

* Allow generic on coerce functions (#4379)

* Allow generic on coerce functions

* Clean up

* Add union values test

* Add another lazy schema init test

* Clean up

* Add docs for recursive type debugging.

* Update recursive type docs

* F

* Improve discriminateduion errors (#4384)

* Remove abort property from ZodTransformDef. Add discriminator key to no_discriminator_found issue.

* Clean up

* Clean up Error inheritance

* Remove examples from JSON Schema when io=input

* `z.toJSONSchema`: Defer execution of `override`, improve ref handling (#4385)

* Defer override execution

* Improve refs in json schema. Cleanup.

* Clean up

* Clean up

* Clean up enum input type

* Improve base64 perf. Disallow padding in base64url. (#4386)

* Improve base64 perf. Disallow padding in base64url

* Allow empty base64 string

* Allow empty base64 string

* Clean up

* Document base64url change

* Tweak

* Fix treeify error invalid_union handling

* fix ensure catchValue is applied correctly on validation error (#4382)

* Simplify object generics, add test for empty objects (#4387)

* Simplify object generics. Add tests for empty object types.

* Fix tests

* Fix tests, rename pickomit

* Fix typo in json-schema.mdx (#4380)

* fix: use JSON.stringify to escape toDotPath keys w/ quotes (#4374)

This should also correctly handle even weirder stuff like newlines in proeprty keys. JSON.stringify should do all the right escaping - if it's a valid JSON string, it's a valid key.

Note: one existing test was updated:
```
expect(z.core.toDotPath(["data[0]", "value"])).toMatchInlineSnapshot(`"data[0].value"`); // <- before
expect(z.core.toDotPath(["data[0]", "value"])).toMatchInlineSnapshot(`"["data[0]"].value"`); // <- after
```

This looks correct to me? Previously it was implying a shape of `{data: [{value: '...'}]}` when actually it should be a shape of `{'data[0]': {value: '...'}}` (updated 12:30)

Co-authored-by: Misha Kaletsky <[email protected]>

* Improve min/max in JSON Schema (#4388)

* Add types for bag. Fix setting of min/max in json schema

* Fix minValue/maxValue

* Improve number tests

* Trim

* Remove type on base class

* Fix err

* Mark internals

* Remove partial record accordion

* Update ecosystem

* Add reference to instanceof Class

* Add JSON Schema (#4390)

* Update prefault changelog

* Lazy initialization in union and discunion

* Clean up util

* Fix override execution order

* Add test for override execution order

* Preserve shape key ordering in result (#4396)

* Clean up object parser

* Fix discriminated union

* Add disc union test

* Fix inheritance on ZodDiscriminatedUnion

* Document metadata inheritance

* Metadata inherited across clones (#4401)

* Add back discriminator to `z.discriminatedUnion()` API (#4402)

* WIP

* Add back discriminator, add benchmark

* Update docs

* Play

* Add disc union test, improve docs

* chore: add oRPC to the API Libraries ecosystem (#4349)

oRPC 1.2.0 has full support for Zod 4, from validation to OpenAPI spec generation

Co-authored-by: Colin McDonnell <[email protected]>

* Update benchmark

* [v3] Allow missing `type` in JWT (#4404)

* WIP

* Improve JWT tests

* Implement pipe optionality. Drop `._zod.optionality` in favor of `._zod.optin` and `._zod.optout`. (#4405)

* Implement pipe optionalty. Switch to optin and optout

* Clean up

* Redirect

* WIP

* Page events

* Move up sponsors

* Try scroller

* Suspense

* No animation

* Add redirects

* Remove logs

* Add Juno (new silver sponsor) (#4408)

* Add Juno (new silver sponsor)

* chore: redo

* chore: redo

* Add redirects

* WIP

* Audit redirects

* Tweak

* v4: Doc updates for release (#4409)

* v4 release updates

* Tweak

* REmove banners

* Add tabs

* Update intro

* Zod 4

* Fix lint

* Simplify readme

* Simplify readme

* Simplify readme

* Simplify readme

---------

Co-authored-by: Chingiz Mammadov <[email protected]>
Co-authored-by: Henrikh Kantuni <[email protected]>
Co-authored-by: Shivam Vijaywargi <[email protected]>
Co-authored-by: Abdalrhman Almarakeby <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Anders Hejlsberg <[email protected]>
Co-authored-by: Andrii Andreichenko <[email protected]>
Co-authored-by: Mohammed Alaa Alhaj <[email protected]>
Co-authored-by: Jonathan Waltz <[email protected]>
Co-authored-by: Ernest <[email protected]>
Co-authored-by: Juan Giordana <[email protected]>
Co-authored-by: Anna Bocharova <[email protected]>
Co-authored-by: xcfox <[email protected]>
Co-authored-by: Shodai Suzuki <[email protected]>
Co-authored-by: Dan Michael O. Heggø <[email protected]>
Co-authored-by: Alexandre Marques <[email protected]>
Co-authored-by: Alexandre Marques <[email protected]>
Co-authored-by: Stijn Van Hulle <[email protected]>
Co-authored-by: George Kormaris <[email protected]>
Co-authored-by: Lakshan Perera <[email protected]>
Co-authored-by: Kevin Damm <[email protected]>
Co-authored-by: Guga Guichard <[email protected]>
Co-authored-by: Timothy Ng <[email protected]>
Co-authored-by: Panda <[email protected]>
Co-authored-by: Panda <[email protected]>
Co-authored-by: Victor Garcia <[email protected]>
Co-authored-by: andrew jarrett <[email protected]>
Co-authored-by: Nolan Di Mare Sullivan <[email protected]>
Co-authored-by: Rik Brown <[email protected]>
Co-authored-by: Kio Yoshimatsu <[email protected]>
Co-authored-by: Helmer <[email protected]>
Co-authored-by: Helmer <[email protected]>
Co-authored-by: Florian Lefebvre <[email protected]>
Co-authored-by: Fabrice Cipolla <[email protected]>
Co-authored-by: Abdullah Mohammed <[email protected]>
Co-authored-by: Hosam Hamdy <[email protected]>
Co-authored-by: Shachar Zidon <[email protected]>
Co-authored-by: Bartosz Szar <[email protected]>
Co-authored-by: Marcel <[email protected]>
Co-authored-by: Dmytro Dobrovolskyi <[email protected]>
Co-authored-by: Henri Södergård <[email protected]>
Co-authored-by: Lőrik Levente <[email protected]>
Co-authored-by: GrahamQuan <[email protected]>
Co-authored-by: Nguyễn Hoàng Trung <[email protected]>
Co-authored-by: Filip Ditrich <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Davide Lombardi <[email protected]>
Co-authored-by: Krisna Wijaya <[email protected]>
Co-authored-by: Griko Nibras <[email protected]>
Co-authored-by: Özgür ÖZALP <[email protected]>
Co-authored-by: Mert Şişmanoğlu <[email protected]>
Co-authored-by: Vlad Sazonau <[email protected]>
Co-authored-by: KadimElifba <[email protected]>
Co-authored-by: Lee Keun Hwee <[email protected]>
Co-authored-by: Mojtaba <[email protected]>
Co-authored-by: Asharib Ali <[email protected]>
Co-authored-by: Antonio <[email protected]>
Co-authored-by: Antonio Ivanovski <[email protected]>
Co-authored-by: Sofiane <[email protected]>
Co-authored-by: Jie Peng <[email protected]>
Co-authored-by: Magne Skutle <[email protected]>
Co-authored-by: Magne Skutle <[email protected]>
Co-authored-by: Steffen Holanger <[email protected]>
Co-authored-by: Thada Wangthammang <[email protected]>
Co-authored-by: Tadej Polajnar <[email protected]>
Co-authored-by: Sasivarnan R <[email protected]>
Co-authored-by: Simon Legner <[email protected]>
Co-authored-by: Pere Montpeó <[email protected]>
Co-authored-by: Khairul Haziq <[email protected]>
Co-authored-by: Jacques <[email protected]>
Co-authored-by: Loris Sigrist <[email protected]>
Co-authored-by: chimame <[email protected]>
Co-authored-by: Fabian Hiller <[email protected]>
Co-authored-by: Misha Kaletsky <[email protected]>
Co-authored-by: Misha Kaletsky <[email protected]>
Co-authored-by: unnoq <[email protected]>
Co-authored-by: David Dal Busco <[email protected]>
RobinTail added a commit to RobinTail/express-zod-api that referenced this pull request May 28, 2025
Related to #2550

## Dedication


![image](https://github.com/user-attachments/assets/0bf05104-d126-4e4b-aa6f-354292ff8dd5)

Ashley Burton was a 37 years young black transgender woman, a
hairstylist and a makeup artist in Atlanta.
She was shot to death at her apartment complex April 11th 2023. 
Her body was found shortly after 4:30 a.m. in the breezeway of her
building.

> She ran out of the house, hollering and screaming, beating on doors.
> This got to be personal. You shot her in her house, then you followed
her outside and shot her.

— _her cousin Ivory Carter told Atlanta TV station WXIA_.

Burton and Carter grew up together in South Carolina.

> She was a sweetheart, she wasn’t nasty. She wasn’t disrespectful. She
just wanted to live her life.
> I’m tired of all these incidents with transgender women just being
pushed up under the rug. We are human beings.

— _Carter said_.

Patrick Burton, the victim’s brother, told Atlanta station WAGA that
“Ashley was very loved all the way across the board, like from South
Carolina to Atlanta.”

Darius Mills, 31, was arrested in June in connection with the crime. He
faces charges of murder, armed robbery, possession of a firearm by a
convicted felon, and possession of a firearm during the commission of a
felony.

https://www.advocate.com/crime/ashley-burton-trans-woman-death

Transgender women suffer [too
frequently](https://www.congress.gov/118/meeting/house/117016/documents/HMKP-118-JU00-20240321-SD015.pdf)
from transphobic violence and cruelty, being the less protected social
group. I'd like to raise an awareness of this problem. Humans should be
creators — not killers. But most importantly, I want every transgender
girl to have an opportunity to create applications quickly and, in
general, learn to write code easily in order to receive job offers and
leave dangerously transphobic territories for more favorable and
civilized ones, and live happily there. Protect transgender women.

## Modern impact


![image](https://github.com/user-attachments/assets/e8f1854d-8581-45f6-8825-9d8f329e8320)

The Trump administration's policies have significantly impacted
transgender individuals, particularly those who are most vulnerable, by
dismantling protections and fostering environments that increase the
risk of discrimination and violence. Here's an overview of how these
policies have affected the transgender community:

### 1. Executive Order 14168: Erasure of Transgender Recognition

On January 20, 2025, President Trump signed Executive Order 14168,
titled "Defending Women from Gender Ideology Extremism and Restoring
Biological Truth to the Federal Government." This order mandates federal
agencies to recognize only two sexes, male and female, determined at
birth, effectively erasing federal recognition of transgender
identities. It also prohibits the use of gender identity in federal
documentation and policies, impacting areas such as passports, housing,
and healthcare. ([Executive Order
14168](https://en.wikipedia.org/wiki/Executive_Order_14168?utm_source=chatgpt.com),
[Trump Administration Moves to Reject Transgender Identity, Rights |
Human Rights
Watch](https://www.hrw.org/news/2025/01/23/trump-administration-moves-reject-transgender-identity-rights?utm_source=chatgpt.com))

### 2. Healthcare Discrimination and Denial of Gender-Affirming Care

The administration rolled back protections under the Affordable Care Act
that previously prohibited discrimination based on gender identity. This
change allows healthcare providers and insurers to deny gender-affirming
treatments, such as hormone therapy and surgeries, which are vital for
the well-being of transgender individuals. ([Trump administration
reverses health protections for transgender people | Trump
administration | The
Guardian](https://www.theguardian.com/us-news/2020/jun/12/trump-transgender-lgbt-healthcare-protections?utm_source=chatgpt.com))

### 3. Restrictions on Access to Shelters

The Department of Housing and Urban Development (HUD) proposed revisions
to the Equal Access Rule, permitting federally funded shelters to deny
access to transgender individuals based on their sex assigned at birth.
This policy change increases the risk of homelessness and exposure to
violence for transgender people seeking safe shelter. ([The Dire
Consequences of the Trump Administration’s Attack on Transgender
People’s Access to Shelters - Center for American
Progress](https://www.americanprogress.org/article/dire-consequences-trump-administrations-attack-transgender-peoples-access-shelters/?utm_source=chatgpt.com))

### 4. Transgender Individuals in the Prison System

Under Executive Order 14168, the Bureau of Prisons is required to house
incarcerated individuals based on their sex assigned at birth, not their
gender identity. This policy has led to transgender women being placed
in men's prisons, where they face heightened risks of sexual assault and
abuse. Additionally, access to gender-affirming healthcare in prisons
has been curtailed. ([Executive Order
14168](https://en.wikipedia.org/wiki/Executive_Order_14168?utm_source=chatgpt.com),
[Trump Administration Moves to Reject Transgender Identity, Rights |
Human Rights
Watch](https://www.hrw.org/news/2025/01/23/trump-administration-moves-reject-transgender-identity-rights?utm_source=chatgpt.com))

### 5. Defunding of LGBTQ+ Support Services

The administration proposed terminating federal funding for specialized
services of the 988 Suicide & Crisis Lifeline that cater to LGBTQ+
youth. These services have been crucial in providing crisis support to
over 1.2 million individuals, and their removal could exacerbate mental
health challenges within the community. ([RFK Jr. Reportedly Wants to
Defund the National Suicide Hotline for LGBTQ+
Youth](https://www.them.us/story/rfk-jr-hhs-suicide-hotline-lgbtq-youth-rfk-jr-trump-administration?utm_source=chatgpt.com))

### 6. Increased Violence Against Transgender Individuals

The rollback of protections and the promotion of policies that
invalidate transgender identities have coincided with a rise in violence
against transgender people. In 2023, at least 29 transgender and
nonbinary individuals were reported killed in the U.S., with many cases
involving women of color. Advocacy groups suggest that the actual number
may be higher due to underreporting and misidentification. ([Trump
Administration Doubles Down on Trans Discrimination | Human Rights
Watch](https://www.hrw.org/news/2020/06/25/trump-administration-doubles-down-trans-discrimination?utm_source=chatgpt.com))

In summary, the Trump administration's policies have systematically
undermined the rights and safety of transgender individuals, leading to
increased discrimination, denial of essential services, and a rise in
violence against the community.

## Summary

Version 24 introduces initial support for Zod 4, requiring at least
version `3.25.1`, but due to the special versioning strategy of Zod all
imports must be changed to `zod/v4`. The framework simplifies the
`IOSchema` type to explicitly require schemas that resolve to objects.
`Documentation` generation now uses Zod 4’s native `toJSONSchema()`
method, with custom overrides to align with OpenAPI 3.1, and the
`numericRange` option has been removed. The `Depicter` type changed its
signature, and `brandHandling` is now implemented as a postprocessing
step. The `optionalPropStyle` option was removed from the `Integration`
constructor. Using the Zod's internal storage for examples: method
`.example()` changed its argument from `z.input<>` to `z.output<>` which
is breaking for transforming schemas, so that examples of its input side
must be set before the transformation. The `getExamples()` helper
removed in favour of `.meta()?.examples`.

### Contains

- #2537 
  - #2549 
  - #2560 
    - #2561
  - #2573 
  - #2574 - decided to split and rethink
  - #2575 
  - #2578
  - #2579
  - #2580 
  - #2584
  - #2589
  - #2600 
  - #2604 
    - #2607 
- #2547 
  - #2553 
  - #2557 
    - #2593
  - #2559 
  - #2556 
  - #2572 
  - #2581 
  - #2582
  - #2583 
- Chores on registries:
  - #2562 
- need to start over keeping immutability in mind and preserving all
meta when adding new ones
  - #2563 - postponed
  - #2566 - idea rejected
  - #2564 
  - #2565 
  - #2567 
  - #2643
  - #2632 
  - #2644
- Chores on migration:
  - #2585 
  - #2586 
- #2595 
  - #2598
  - #2599 
- #2631
- #2633 
- #2637
- #2651 
- #2649 
  - #2652 
- #2656
- #2664 
  - 57d08c9
- #2665 
- #2666 
- #2668 
- #2670 

### External bugs

![bug on
buggy](https://github.com/user-attachments/assets/e4eefacc-2bb6-4db7-9e6a-2641c582f13a)

- colinhacks/zod#4234
- colinhacks/zod#4228
- colinhacks/zod#4159
- colinhacks/zod#4152
- colinhacks/zod#4224
- colinhacks/zod#4274
- colinhacks/zod#4275 — This one especially
freaks me out
- colinhacks/zod#4267
- colinhacks/zod#4309 - important
- colinhacks/zod#4317
- colinhacks/zod#4318
- colinhacks/zod#4320
- colinhacks/zod#4322

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced `ez.buffer()` schema for Node.js Buffer validation,
replacing `ez.file()`.
- Enhanced OpenAPI documentation generation using Zod 4’s native
`toJSONSchema()` with improved depiction helpers.
- Added JSON Schema flattening utilities for improved schema processing.
- Improved endpoint result handling with discriminated result types and
integrated output example registration.

- **Breaking Changes**
- Removed simultaneous support for Zod 3 and 4; all imports now use
`zod/v4`.
- Deprecated `ez.file()` schema removed; replaced by `z.string()`,
`z.base64()`, or `ez.buffer()`.
  - Simplified `IOSchema` to accept only object schemas.
- `.example()` now aliases `.meta({ examples })` with updated semantics
and example placement.
- Removed `numericRange` and `optionalPropStyle` options from
constructors.
- Branding refactored to use internal Zod checks instead of metadata
cloning.
- Endpoint request type detection updated to use brand-based schema
identification.
  - Refined type signatures and removed deprecated helpers and types.

- **Bug Fixes**
- Improved error handling and diagnostics for schema validation,
including cycle detection.
  - Fixed example metadata immutability and accumulation.
- Enhanced output example extraction and registration via Zod global
registry.

- **Documentation**
- Updated README and CHANGELOG with new features and migration guidance.
- Clarified and improved code samples, especially for date handling and
non-JSON responses.
- Strengthened OpenAPI schema generation with stricter validation,
examples, and additional properties control.

- **Style**
- Migrated all code and tests to use `zod/v4` imports and updated schema
definitions.
- Simplified schema walking and depiction using Zod v4 JSON schema
output and overrides.
  - Consolidated and cleaned middleware and factory type constraints.
- Refactored branding, metadata, and example handling for better
maintainability.

- **Tests**
- Added tests for buffer schema, deep schema checks, JSON schema
helpers, migration rules, and environment validations.
- Removed tests for deprecated features and schemas such as `ez.file()`.
- Enhanced coverage for error classes, diagnostics, branding
persistence, and example extraction.
- Updated snapshots and assertions to align with Zod v4 internals and
behaviors.

- **Chores**
- Updated CI workflows to target new branches and remove legacy
triggers.
  - Added `pretest` script for type checking before tests.
  - Updated security policy to support version 24.x.x.
  - Rewrote migration ESLint rule for v24 API and schema changes.
- Improved Vitest serializers for Zod errors and schemas with brand
metadata.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants