wip
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
*
|
||||
* Represents a valid league name with validation rules.
|
||||
*/
|
||||
|
||||
|
||||
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
||||
import type { IValueObject } from '@gridpilot/shared/domain';
|
||||
|
||||
export interface LeagueNameValidationResult {
|
||||
valid: boolean;
|
||||
@@ -22,7 +23,11 @@ export const LEAGUE_NAME_CONSTRAINTS = {
|
||||
],
|
||||
} as const;
|
||||
|
||||
export class LeagueName {
|
||||
export interface LeagueNameProps {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export class LeagueName implements IValueObject<LeagueNameProps> {
|
||||
readonly value: string;
|
||||
|
||||
private constructor(value: string) {
|
||||
@@ -83,6 +88,10 @@ export class LeagueName {
|
||||
return new LeagueName(value.trim());
|
||||
}
|
||||
|
||||
get props(): LeagueNameProps {
|
||||
return { value: this.value };
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to create a LeagueName, returning null if invalid
|
||||
*/
|
||||
@@ -97,8 +106,8 @@ export class LeagueName {
|
||||
toString(): string {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: LeagueName): boolean {
|
||||
return this.value === other.value;
|
||||
|
||||
equals(other: IValueObject<LeagueNameProps>): boolean {
|
||||
return this.props.value === other.props.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user