export default class ValueObject { private readonly value: string; constructor(value: string) { if (!value) { throw new ValidationError("ValueObject value cannot be empty"); } this.value = value; } map(fn: (value: string) => string): ValueObject { return new ValueObject(fn(this.value)); } equals(otherValue: ValueObject): boolean { return otherValue.value === this.value; } valueOf(): string { return this.value; } static create(value: string): Result { try { let val = new ValueObject(value); return ok(val); } catch (error) { return err(error); } } }