@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
20 lines • 622 B
JavaScript
import { createId, isCuid } from '@paralleldrive/cuid2';
import { ensure, matches, or, Predicate, TinyType } from 'tiny-types';
export class CorrelationId extends TinyType {
value;
static fromJSON(v) {
return new CorrelationId(v);
}
static create() {
return new CorrelationId(createId());
}
constructor(value) {
super();
this.value = value;
ensure(this.constructor.name, value, or(isACuid(), matches(/^[\d.A-Za-z-]+$/)));
}
}
function isACuid() {
return Predicate.to(`be a Cuid`, (value) => isCuid(value));
}
//# sourceMappingURL=CorrelationId.js.map