Skip to content

fromJSONSchema date-time rejects valid RFC 3339 offsets #6296

Description

@agcty

fromJSONSchema({ type: "string", format: "date-time" }) currently maps to z.iso.datetime() and rejects valid RFC 3339 timestamps with numeric UTC offsets.

const schema = z.fromJSONSchema({ type: "string", format: "date-time" });

schema.parse("2026-07-29T14:30:00Z"); // accepted
schema.parse("2026-07-29T16:30:00+02:00"); // rejected

JSON Schema defines date-time using RFC 3339, where both Z and numeric offsets are valid. A local timestamp without an offset should remain invalid.

The mapping can preserve that behavior by using z.iso.datetime({ offset: true }). Authored JSON Schema constraints such as pattern should continue to compose with the format check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions