UNPKG

rich-domain

Version:

This package provide utils file and interfaces to assistant build a complex application with domain driving design

24 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = validateContextEventName; /** * @description Validates the format of an event name to ensure it follows the required pattern. * The expected pattern is `"contextName:EventName"`, where the event name must include a colon (`":"`) * to separate the context name and the event name. * * @param eventName The event name to validate. Must be a string containing a colon (`":"`). * * @throws {Error} Throws an error if the event name does not include a colon (`":"`). * * @example * ```typescript * validateContextEventName("user:created"); // Passes validation * validateContextEventName("invalidEventName"); // Throws an error * ``` */ function validateContextEventName(eventName) { const message = 'Validation failed: Event name must follow the pattern "contextName:EventName". Please ensure to include a colon (":") in the event name to separate the context name and the event name itself.'; if (!eventName.includes(':')) throw new Error(message); } //# sourceMappingURL=validate-context-event-name.util.js.map