@hexadrop/value-object
Version:
Hexagonal architecture utils library
61 lines (59 loc) • 2.48 kB
TypeScript
interface ToDateObject {
toDate(): Date;
}
/**
* DateValueObject is a class that represents a date value object.
* It provides methods to compare the date value with other DateValueObject instances.
*/
declare class DateValueObject {
/**
* The value of the date.
*/
readonly value: Date;
/**
* Constructs a new DateValueObject instance.
* @param {Date | string | number} value - The value of the date.
* @param {string} [property] - The property name (optional).
* @throws {InvalidDateValueTypeError} If the value is not a Date instance.
* @throws {EmptyDateValueError} If the value is null or undefined.
*/
constructor(value: Date | number | string | ToDateObject, property?: string);
/**
* Checks if the value is a Date instance.
* @param {unknown} value - The value to check.
* @param {string} [property] - The property name (optional).
* @throws {InvalidDateValueTypeError} If the value is not a Date instance.
*/
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 {EmptyDateValueError} If the value is null or undefined.
*/
private static notEmpty;
/**
* Checks if the date value is after the other DateValueObject's date value.
* @param {DateValueObject} other - The other DateValueObject to compare with.
* @returns {boolean} True if the date value is after, false otherwise.
*/
isAfterThan(other: DateValueObject): boolean;
/**
* Checks if the date value is before the other DateValueObject's date value.
* @param {DateValueObject} other - The other DateValueObject to compare with.
* @returns {boolean} True if the date value is before, false otherwise.
*/
isBeforeThan(other: DateValueObject): boolean;
/**
* Checks if the date value is equal to the other DateValueObject's date value.
* @param {DateValueObject} other - The other DateValueObject to compare with.
* @returns {boolean} True if the date values are equal, false otherwise.
*/
isEqualsTo(other: DateValueObject): boolean;
/**
* Converts the date value to a string in ISO format.
* @returns {string} The string representation of the date value in ISO format.
*/
toString(): string;
}
export { DateValueObject as default };