Files
gridpilot.gg/core/racing/domain/entities/VideoUrl.ts
2025-12-17 00:33:13 +01:00

26 lines
657 B
TypeScript

import { RacingDomainValidationError } from '../errors/RacingDomainError';
export class VideoUrl {
private constructor(private readonly value: string) {}
static create(value: string): VideoUrl {
if (!value || value.trim().length === 0) {
throw new RacingDomainValidationError('Video URL cannot be empty');
}
// Basic URL validation
try {
new URL(value);
} catch {
throw new RacingDomainValidationError('Invalid video URL format');
}
return new VideoUrl(value.trim());
}
toString(): string {
return this.value;
}
equals(other: VideoUrl): boolean {
return this.value === other.value;
}
}