Skip to content

Conversation

@pullfrog
Copy link
Contributor

@pullfrog pullfrog bot commented Jan 29, 2026

Summary

z.iso.time().toJSONSchema() was not including the format field in its output, contrary to the documentation which states:

z.iso.time(); // => { type: "string", format: "time" }

Changes

Removed the special-case logic in json-schema-processors.ts that was explicitly deleting the format field for time schemas. The original code had this comment:

// JSON Schema format: "time" requires a full time with offset or Z
// z.iso.time() does not include timezone information, so format: "time" should never be used

While technically JSON Schema's time format expects timezone info, the pattern regex already ensures correct validation for Zod's local time format. The format field serves as a hint for tooling and should match the documented behavior.

Before

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$"
}

After

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "format": "time",
  "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$"
}

Closes #5673

Pullfrog  | Triggered by Pullfrog | Using Claude CodeView workflow runpullfrog.com𝕏

Remove special-case logic that was stripping the `format` field for time
schemas. The pattern already ensures correct validation, and the format
field is documented to be included per the JSON Schema conversion docs.
@colinhacks colinhacks closed this Feb 8, 2026
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.

z.iso.time() is missing the format property in toJSONSchema

2 participants