Integer
Whole-number value object.
Import
typescript
import { Integer } from '@haskou/value-objects';Signature
typescript
class Integer extends NumberValueObjectConstructor
typescript
constructor(value: number | NumberValueObject)Validation
The value must be a number with no fractional part.
Throws
This class can throw:
InvalidIntegerErrorInvalidNumberError
Example
typescript
import { Integer } from '@haskou/value-objects';
const count = new Integer(42);
count.valueOf(); // 42
count.add(8).valueOf(); // 50Notes
- Arithmetic methods are inherited from
NumberValueObject. - Arithmetic results are returned through the base number behavior, not revalidated as
Integerafter every operation.