A social knowledge tool for researchers built on ATProto
1import { ValueObject } from 'src/shared/domain/ValueObject'; 2import { err, ok, Result } from 'src/shared/core/Result'; 3 4interface DIDProps { 5 value: string; 6} 7 8export class DID extends ValueObject<DIDProps> { 9 get value(): string { 10 return this.props.value; 11 } 12 13 private constructor(props: DIDProps) { 14 super(props); 15 } 16 17 public static create(did: string): Result<DID> { 18 if (!did || !did.startsWith('did:plc:')) { 19 return err(new Error("Invalid DID format. Must start with 'did:plc:'")); 20 } 21 22 return ok(new DID({ value: did })); 23 } 24 25 public toString(): string { 26 return this.props.value; 27 } 28}