Skip to content

fix(time): 🐛 Fix Hour validation and minute wrapping - #8

Merged
haskou merged 2 commits into
masterfrom
fix/hour-validation-minute-wrapping
Jun 7, 2026
Merged

haskou merged 2 commits into
masterfrom
fix/hour-validation-minute-wrapping

Conversation

@haskou

@haskou haskou commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent malformed or fractional inputs from being silently accepted by Hour, and ensure minute arithmetic wraps correctly across day boundaries.
  • Improve robustness of time value parsing to avoid surprising normalization of invalid inputs.

Description

  • Add FORMAT_REGEX and strict parsing helpers parseFromString and parseFromNumber to reject malformed strings and fractional numeric values in Hour.
  • Replace loose string-to-number normalization with explicit validation and zero-padding via addTrailZero for consistent representation in Hour.
  • Implement normalizeMinutes and update addMinutes to use modular arithmetic so additions/subtractions spanning multiple days wrap correctly.
  • Add regression tests in tests/value-objects/time/Hour.spec.ts for invalid formats, fractional inputs, and multi-day minute arithmetic.

Testing

  • Ran linter with yarn lint and it passed successfully.
  • Ran focused unit tests with yarn test:unit --runInBand tests/value-objects/time/Hour.spec.ts and the Hour test suite passed.
  • Ran the full unit test suite with yarn test:unit --runInBand and all tests passed (39 test suites, 709 tests).
  • Built the project with yarn build and the build completed successfully.

Supersedes #2.

Codex Task

@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: 1a573f2318

ℹ️ 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/Hour.ts Outdated
@codecov-commenter

codecov-commenter commented Jun 7, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@haskou
haskou merged commit a62c1b4 into master Jun 7, 2026
2 checks passed
@haskou
haskou deleted the fix/hour-validation-minute-wrapping branch June 7, 2026 08:35
github-actions Bot added a commit that referenced this pull request Jun 7, 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.

2 participants