Skip to content

Fix Hour validation and minute wrapping - #2

Closed
haskou wants to merge 1 commit into
masterfrom
codex/identify-issues-and-open-pr
Closed

haskou wants to merge 1 commit into
masterfrom
codex/identify-issues-and-open-pr

Conversation

@haskou

@haskou haskou commented May 11, 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.

Codex Task

haskou commented Jun 7, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #8, which uses the fix/* release branch prefix and a squash-merge-ready conventional commit title with gitmoji.

@haskou haskou closed this Jun 7, 2026
@haskou
haskou deleted the codex/identify-issues-and-open-pr branch June 7, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant