import { Type } from 'class-transformer'; import { ArrayMaxSize, ArrayMinSize, IsArray, IsDate, IsEnum, IsInt, IsOptional, IsString, MaxLength, Min, MinLength, ValidateNested, } from 'class-validator'; import { POSITIONS } from '../../global/database/schema'; import type { Position } from '../../global/database/schema'; export class PositionPreferenceDto { @IsEnum(POSITIONS) position!: Position; @IsInt() @Min(1) priority!: number; } class MatchScheduleItemDto { @IsString() @MaxLength(32) time!: string; @IsString() @MaxLength(128) label!: string; } export class CreateMatchDto { @IsString() @MinLength(1) @MaxLength(128) title!: string; @IsOptional() @IsString() @MaxLength(2048) description?: string; @IsOptional() @IsInt() mapId?: number; @IsDate() @Type(() => Date) scheduledAt!: Date; @IsOptional() @IsInt() @Min(2) maxParticipants?: number; @IsOptional() @IsArray() @IsString({ each: true }) @ArrayMaxSize(32) prizes?: string[]; @IsOptional() @IsArray() @IsString({ each: true }) @ArrayMaxSize(32) notices?: string[]; @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => MatchScheduleItemDto) @ArrayMaxSize(32) schedule?: MatchScheduleItemDto[]; } export class UpdateMatchDto { @IsOptional() @IsString() @MaxLength(128) title?: string; @IsOptional() @IsString() @MaxLength(2048) description?: string; @IsOptional() @IsInt() mapId?: number; @IsOptional() @IsDate() @Type(() => Date) scheduledAt?: Date; @IsOptional() @IsInt() @Min(2) maxParticipants?: number; @IsOptional() @IsArray() @IsString({ each: true }) prizes?: string[]; @IsOptional() @IsArray() @IsString({ each: true }) notices?: string[]; @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => MatchScheduleItemDto) schedule?: MatchScheduleItemDto[]; } export class JoinMatchDto { @IsArray() @ArrayMinSize(1) @ArrayMaxSize(5) @ValidateNested({ each: true }) @Type(() => PositionPreferenceDto) preferredPositions!: PositionPreferenceDto[]; @IsOptional() @IsString() userId?: string; }