Conversation
…idation
When strictDates is enabled, dateTimeOffset controls whether datetime schemas
generate z.string().datetime({ offset: true }) (accepting both 'Z' and '+HH:MM')
or z.string().datetime() (accepting only 'Z'). Defaults to true.
Supports boolean (all-or-nothing) and string[] (per-schema) control.
…maName Separate ownName from currentSchemaName in getZodTypeFromSchema so that dateTimeOffset array matching only applies to top-level named schemas, not to inline properties inside object schemas. Previously, an object schema named 'Account' in the dateTimeOffset array would incorrectly apply offset to its inline date-time properties. Also adds dateTimeOffset to CLI help text and integration tests for CLI config pass-through and empty array edge case.
📝 WalkthroughWalkthroughAdds a dateTimeOffset option (boolean | string[]) controlling whether Zod datetime validators include timezone offsets when strictDates is enabled; integrates the option across specs, CLI, config schema, core schema generation, and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI / Config
participant Runner as generateWithMetadata
participant SchemaGen as schema-generator
participant Builder as buildString
participant Zod as Zod Output
CLI->>Runner: pass dateTimeOffset
Runner->>SchemaGen: build SchemaOptions (dateTimeOffset, strictDates)
SchemaGen->>SchemaGen: getZodTypeFromSchema(schema, ..., ownName)
SchemaGen->>Builder: buildString(schema, SchemaOptions, schemaName)
alt strictDates AND dateTimeOffset applies
Builder->>Zod: z.string().datetime({ offset: true })
else
Builder->>Zod: z.string().datetime()
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #68 +/- ##
==========================================
+ Coverage 97.32% 97.34% +0.02%
==========================================
Files 16 16
Lines 2171 2188 +17
==========================================
+ Hits 2113 2130 +17
Misses 58 58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/zenko/src/zenko.ts`:
- Line 104: The defaulting of dateTimeOffset to true causes
z.string().datetime({ offset: true }) for existing strictDates users and expands
allowed inputs; change the default behavior so existing users keep the previous
validation: set dateTimeOffset to false (or undefined) unless explicitly
enabled, and ensure the code path that builds the schema (the place using
dateTimeOffset when strictDates is true to call z.string().datetime(...)) only
passes { offset: true } when the user explicitly requested offset support;
update references to dateTimeOffset and strictDates (and the z.string().datetime
call) accordingly and add a brief changelog note if you intend to keep a
behavior change.
Summary by CodeRabbit