Repository navigation
v3.0.0
Changes
- fix(value-objects)!: 💥 Enforce strict validation and immutability
Release details
- npm: https://www.npmjs.com/package/@haskou/value-objects/v/3.0.0
- Pull request: #29
- Source branch:
break/harden-value-object-validation - Version bump:
major
Pull request notes
Summary
- Remove
TimestampInterval.modifyStart()andmodifyEnd()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
Durationday and hour component calculations.
Breaking changes
TimestampInterval.modifyStart()andmodifyEnd()are no longer available.NumberValueObject,Integer, andTimestamprejectInfinity,-Infinity, and invalid date values.UUIDrejects 36-character strings that do not match the standard UUID structure.CalendarDayrejects normalized dates such as2022-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 buildyarn docs:build- Prettier check for all changed files