UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

24 lines 834 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CorrelationId = void 0; const cuid2_1 = require("@paralleldrive/cuid2"); const tiny_types_1 = require("tiny-types"); class CorrelationId extends tiny_types_1.TinyType { value; static fromJSON(v) { return new CorrelationId(v); } static create() { return new CorrelationId((0, cuid2_1.createId)()); } constructor(value) { super(); this.value = value; (0, tiny_types_1.ensure)(this.constructor.name, value, (0, tiny_types_1.or)(isACuid(), (0, tiny_types_1.matches)(/^[\d.A-Za-z-]+$/))); } } exports.CorrelationId = CorrelationId; function isACuid() { return tiny_types_1.Predicate.to(`be a Cuid`, (value) => (0, cuid2_1.isCuid)(value)); } //# sourceMappingURL=CorrelationId.js.map