refactor
This commit is contained in:
25
core/racing/domain/entities/ProtestStatus.ts
Normal file
25
core/racing/domain/entities/ProtestStatus.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
||||
|
||||
export type ProtestStatusValue = 'pending' | 'awaiting_defense' | 'under_review' | 'upheld' | 'dismissed' | 'withdrawn';
|
||||
|
||||
export class ProtestStatus {
|
||||
private constructor(private readonly value: ProtestStatusValue) {}
|
||||
|
||||
static create(value: string): ProtestStatus {
|
||||
const validStatuses: ProtestStatusValue[] = ['pending', 'awaiting_defense', 'under_review', 'upheld', 'dismissed', 'withdrawn'];
|
||||
|
||||
if (!validStatuses.includes(value as ProtestStatusValue)) {
|
||||
throw new RacingDomainValidationError(`Invalid protest status: ${value}`);
|
||||
}
|
||||
|
||||
return new ProtestStatus(value as ProtestStatusValue);
|
||||
}
|
||||
|
||||
toString(): ProtestStatusValue {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: ProtestStatus): boolean {
|
||||
return this.value === other.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user