Make Schema.Date reject invalid dates#6620
Conversation
🦋 Changeset detectedLatest commit: 66cff9b The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthrough
ChangesDate validation consolidation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
Bundle Size Analysis
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/effect/src/Schema.ts`:
- Around line 12082-12083: Update the Date guard passed to declare so invalid
forged or proxied Date-like values cannot throw during getTime(). Catch
exceptions from the validity check and return false, while preserving true for
genuine, non-NaN globalThis.Date instances.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f4e91bcf-0d8f-4eae-a617-a379c94c2f3e
📒 Files selected for processing (20)
.changeset/schema-date-valid.mdmigration/schema.mdpackages/effect/SCHEMA.mdpackages/effect/src/Config.tspackages/effect/src/Schema.tspackages/effect/src/SchemaTransformation.tspackages/effect/src/internal/schema/toArbitrary.tspackages/effect/src/unstable/cli/Primitive.tspackages/effect/test/Config.test.tspackages/effect/test/schema/Schema.test.tspackages/effect/test/schema/representation/builtInRevivers.test.tspackages/effect/test/schema/representation/toCodeDocument.test.tspackages/effect/test/schema/toArbitrary.test.tspackages/effect/test/schema/toDifferJsonPatch.test.tspackages/effect/test/schema/toIso.test.tspackages/effect/test/schema/toJsonSchemaDocument.test.tspackages/effect/test/unstable/cli/Primitive.test.tspackages/effect/typetest/schema/SchemaBuiltInDateRevivers.tst.tspackages/effect/typetest/schema/toIso.tst.tspackages/platform-browser/src/IndexedDb.ts
💤 Files with no reviewable changes (4)
- packages/effect/test/schema/representation/builtInRevivers.test.ts
- packages/effect/typetest/schema/SchemaBuiltInDateRevivers.tst.ts
- packages/effect/test/schema/toJsonSchemaDocument.test.ts
- packages/effect/test/schema/representation/toCodeDocument.test.ts
Summary by CodeRabbit
New Features
Datevalues across schemas, configuration, CLI parsing, and IndexedDB keys.Breaking Changes
DateValidschema and related date-validation helpers.Documentation