import { PartialType } from '@nestjs/mapped-types';
import { CreateSeasonDto } from './create-season.dto';
import { IsOptional, ValidateIf, Matches } from 'class-validator';
import { Transform } from 'class-transformer';

export class UpdateSeasonDto extends PartialType(CreateSeasonDto) {
  @ValidateIf((o) => o.start_date !== null && o.start_date !== undefined)
  @Matches(/^\d{2}-\d{2}$/, { message: 'start_date must be in MM-DD format (e.g. 03-15)' })
  @IsOptional()
  @Transform(({ value }) => value === null ? null : value)
  declare start_date?: string;

  @ValidateIf((o) => o.end_date !== null && o.end_date !== undefined)
  @Matches(/^\d{2}-\d{2}$/, { message: 'end_date must be in MM-DD format (e.g. 12-20)' })
  @IsOptional()
  @Transform(({ value }) => value === null ? null : value)
  declare end_date?: string;
}
