UNPKG

@hexadrop/value-object

Version:

Hexagonal architecture utils library

40 lines (37 loc) 1.37 kB
import StringValueObject from './string.value-object.js'; /** * UlidValueObject is an abstract class that represents a ULID value object. * It extends the StringValueObject class and provides additional methods for validating the ULID value. */ declare abstract class UlidValueObject extends StringValueObject { /** * Constructs a new UlidValueObject instance. * * @param value - The ULID value. * @param property - Optional. The property name. * @throws {InvalidUlidValueError} If the value is not a valid ULID. */ constructor(value: string, property?: string); /** * Generates a random ULID. * * @param {number} [seedTime] - Optional. The seed time to use for generating the ULID. If not provided, the current time is used. * @returns {string} The generated ULID. */ static random(seedTime?: number): string; /** * Checks if the value is a valid ULID. * * @param id - The value to check. * @param property - Optional. The property name. * @throws {InvalidUlidValueError} If the value is not a valid ULID. */ private static ensureIsValidUlid; /** * Retrieves the timestamp from the ULID value. * * @returns {number} The timestamp in milliseconds since the Unix epoch. */ getTime(): number; } export { UlidValueObject as default };