Skip to content

Comments

fix: improve invalid date handling in deepEqual and validation#13230

Merged
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom
a28689604:fix/invalid-date-comparison-deepequal
Jan 1, 2026
Merged

fix: improve invalid date handling in deepEqual and validation#13230
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom
a28689604:fix/invalid-date-comparison-deepequal

Conversation

@a28689604
Copy link
Contributor

@a28689604 a28689604 commented Jan 1, 2026

Proposed Changes

Fixes validation not triggering in onChange mode when using invalid date values from date libraries like Dayjs.
Invalid Date objects now correctly compare as equal since their NaN timestamps are properly handled by Object.is().

Fixes #13224

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

- Use Object.is() for Date timestamp comparison to handle NaN correctly
- Detect invalid date-like objects (Dayjs, Moment) via getTime() method
- Add comprehensive test coverage for invalid Date comparisons

Signed-off-by: a28689604 <[email protected]>
@bluebill1049 bluebill1049 merged commit 29885bb into react-hook-form:master Jan 1, 2026
6 checks passed
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.

issue: no errors object is created on change for Dayjs validation, deepEqual problem of Date objects

2 participants