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 HandleProps {
5 value: string;
6}
7
8export class Handle extends ValueObject<HandleProps> {
9 get value(): string {
10 return this.props.value;
11 }
12
13 private constructor(props: HandleProps) {
14 super(props);
15 }
16
17 public static create(handle: string): Result<Handle> {
18 // Basic handle validation - can be enhanced
19 if (!handle || !handle.includes('.')) {
20 return err(
21 new Error(
22 'Invalid handle format. Must include a domain (e.g., user.bsky.social)',
23 ),
24 );
25 }
26
27 return ok(new Handle({ value: handle }));
28 }
29
30 public toString(): string {
31 return this.props.value;
32 }
33}