UNPKG

@hexadrop/value-object

Version:

Hexagonal architecture utils library

59 lines (57 loc) 2.46 kB
/** * NumberValueObject is an abstract class that represents a number value object. * It provides methods to compare the number value with other NumberValueObject instances. */ declare abstract class NumberValueObject { /** * The value of the number. */ readonly value: number; /** * Constructs a new NumberValueObject instance. * @param {number} value - The value of the number. * @param {string} [property] - The property name (optional). * @throws {InvalidNumberValueTypeError} If the value is not a number. * @throws {EmptyNumberValueError} If the value is null or undefined. */ constructor(value: number, property?: string); /** * Checks if the value is a number. * @param {unknown} value - The value to check. * @param {string} [property] - The property name (optional). * @throws {InvalidNumberValueTypeError} If the value is not a number. */ private static allowedValue; /** * Checks if the value is not null or undefined. * @param {unknown} value - The value to check. * @param {string} [property] - The property name (optional). * @throws {EmptyNumberValueError} If the value is null or undefined. */ private static notEmpty; /** * Checks if the value is bigger than the other NumberValueObject's value. * @param {NumberValueObject} other - The other NumberValueObject to compare with. * @returns {boolean} True if the value is bigger, false otherwise. */ isBiggerThan(other: NumberValueObject): boolean; /** * Checks if the value is equal to the other NumberValueObject's value. * @param {NumberValueObject} other - The other NumberValueObject to compare with. * @returns {boolean} True if the values are equal, false otherwise. */ isEqualsTo(other: NumberValueObject): boolean; /** * Checks if the value is lesser than the other NumberValueObject's value. * @param {NumberValueObject} other - The other NumberValueObject to compare with. * @returns {boolean} True if the value is lesser, false otherwise. */ isLesserThan(other: NumberValueObject): boolean; /** * Converts the value to a string. * @param {number} [radix] - The radix to use for the conversion (optional). * @returns {string} The string representation of the value. */ toString(radix?: number): string; } export { NumberValueObject as default };