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

26 lines
657 B
TypeScript

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