UNPKG

@hexadrop/value-object

Version:

Hexagonal architecture utils library

47 lines (45 loc) 1.77 kB
/** * BooleanValueObject is an abstract class that represents a boolean value object. * It provides methods to ensure the value is not empty and is of the correct type. * It also provides methods to compare the value with another BooleanValueObject and to convert the value to a string. */ declare abstract class BooleanValueObject { /** * The boolean value. */ readonly value: boolean; /** * Constructs a new BooleanValueObject. * @param value - The boolean value. * @param property - The name of the property (optional). * @throws {EmptyBooleanValueError} If the value is null or undefined. * @throws {InvalidBooleanValueTypeError} If the value is not a boolean. */ constructor(value: boolean, property?: string); /** * Checks if the value is a boolean. * @param value - The value to check. * @param property - The name of the property (optional). * @throws {InvalidBooleanValueTypeError} If the value is not a boolean. */ private static allowedValue; /** * Checks if the value is not empty. * @param value - The value to check. * @param property - The name of the property (optional). * @throws {EmptyBooleanValueError} If the value is null or undefined. */ private static notEmpty; /** * Compares the value with another BooleanValueObject. * @param other - The other BooleanValueObject to compare with. * @returns {boolean} True if the values are equal, false otherwise. */ isEqualsTo(other: BooleanValueObject): boolean; /** * Converts the value to a string. * @returns {string} The string representation of the value. */ toString(): string; } export { BooleanValueObject as default };