Skip to content

feat: support format: "hostname" in fromJSONSchema - #6305

Open
catdalfonso wants to merge 1 commit into
colinhacks:mainfrom
catdalfonso:feat/from-json-schema-hostname-format
Open

feat: support format: "hostname" in fromJSONSchema#6305
catdalfonso wants to merge 1 commit into
colinhacks:mainfrom
catdalfonso:feat/from-json-schema-hostname-format

Conversation

@catdalfonso

Copy link
Copy Markdown

fromJSONSchema maps string formats onto Zod checks but had no branch for
hostname, so those schemas fell through to a plain string and accepted any
value. z.hostname() already exists, so this wires it up alongside the other
network formats.

Round-trips cleanly, since toJSONSchema() already emits format: "hostname"
for z.hostname().

Closes #6304

`fromJSONSchema` maps JSON Schema string formats onto Zod checks, but had
no branch for `hostname`, so such schemas fell through to a plain string
and silently accepted any value. Zod already ships `z.hostname()`, so wire
it up alongside the other network formats.

This also makes the conversion round-trip: `toJSONSchema()` already emits
`format: "hostname"` for `z.hostname()`.

Closes colinhacks#6304

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

fromJSONSchema doesn't support format:hostname (but could)

1 participant