Repository navigation
v8.4.2
Changes
- fix(positive-integer): 🐛 Extend PositiveNumber instead of Integer
Release details
- npm: https://www.npmjs.com/package/@haskou/value-objects/v/8.4.2
- Pull request: #100
- Source branch:
fix/positive-integer-extends-positive-number - Version bump:
patch
Pull request notes
What
PositiveInteger now extends PositiveNumber instead of Integer. PositiveNumber validates the sign and PositiveInteger adds the integer check (InvalidIntegerError).
Behaviour changes
new PositiveInteger(1) instanceof Integeris nowfalse. Code typing a parameter asIntegerand passing aPositiveIntegerwill stop compiling.FileSizeis the only consumer in this repo and is unaffected.- The sign is validated first, so
new PositiveInteger(-0.5)throwsInvalidPositiveNumberError(it used to throwInvalidIntegerError). - The
% 1 === 0check now exists in bothIntegerandPositiveInteger.
Docs and tests
docs/reference/positive-integer.md updated (signature and notes). Spec now asserts inheritance from PositiveNumber, no inheritance from Integer, and the new error for -0.5.
Verification
yarn test (717 tests) and yarn build pass. Coverage stays at 100%.