export class CollectionName {
private readonly value: string;
constructor(name: string) {
if (!name || name.trim().length === 0) {
throw new Error('Collection name cannot be empty');
}
if (name.length > 120) {
throw new Error('Collection name cannot exceed 120 characters');
}
if (name.startsWith('system.')) {
throw new Error('Collection name cannot start with "system."');
}
if (!/^[a-zA-Z0-9_.-]+$/.test(name)) {
throw new Error(
'Collection name can only contain alphanumeric characters, underscores, hyphens, and dots',
);
}
this.value = name;
}
getValue(): string {
return this.value;
}
equals(other: CollectionName): boolean {
return this.value === other.value;
}
toString(): string {
return this.value;
}
}