Skip to content

fix(value-objects)!: 💥 Enforce strict validation and immutability - #29

Merged
haskou merged 2 commits into
masterfrom
break/harden-value-object-validation
Jul 10, 2026
Merged

haskou merged 2 commits into
masterfrom
break/harden-value-object-validation

Conversation

@haskou

@haskou haskou commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove TimestampInterval.modifyStart() and modifyEnd() so interval boundaries remain immutable.
  • Reject non-finite numbers and invalid timestamps.
  • Validate real calendar dates and preserve Unix epoch input.
  • Validate UUID structure, version, and RFC variant.
  • Correct Duration day and hour component calculations.

Breaking changes

  • TimestampInterval.modifyStart() and modifyEnd() are no longer available.
  • NumberValueObject, Integer, and Timestamp reject Infinity, -Infinity, and invalid date values.
  • UUID rejects 36-character strings that do not match the standard UUID structure.
  • CalendarDay rejects normalized dates such as 2022-02-31.

Root cause

Several validators delegated to permissive JavaScript behavior. Date normalized nonexistent dates, numeric validation rejected only NaN, and the UUID pattern checked character count without checking field structure. Duration.getHours() used seconds per hour as its modulo, and mutable timestamp intervals left the inherited primitive value out of sync with their boundaries.

Validation

  • yarn test (808 tests)
  • yarn test:coverage (100% statements, branches, functions, and lines)
  • yarn build
  • yarn docs:build
  • Prettier check for all changed files

@codecov

codecov Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@haskou haskou changed the title Enforce strict validation and immutable timestamp intervals fix(value-objects)!: 💥 Enforce strict validation and immutability Jul 10, 2026
@haskou
haskou marked this pull request as ready for review July 10, 2026 13:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1be53d804a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/value-objects/time/Timestamp.ts Resolved
Comment thread src/value-objects/ids/UUID.ts Resolved
@haskou
haskou merged commit 719c7dc into master Jul 10, 2026
3 checks passed
@haskou
haskou deleted the break/harden-value-object-validation branch July 10, 2026 14:35
github-actions Bot added a commit that referenced this pull request Jul 10, 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.

1 participant