import { ApiProperty } from '@nestjs/swagger';
import { TrainCheckpointKind } from '@edr/types';
import {
  IsEnum,
  IsInt,
  IsISO8601,
  IsOptional,
  IsString,
  MaxLength,
  Min,
} from 'class-validator';

export class RecordCheckpointDto {
  @ApiProperty({ description: 'Station position along the route (0 = origin).' })
  @IsInt()
  @Min(0)
  sequenceNo!: number;

  @ApiProperty({ enum: TrainCheckpointKind, required: false })
  @IsOptional()
  @IsEnum(TrainCheckpointKind)
  kind?: TrainCheckpointKind;

  @ApiProperty({ required: false, description: 'ISO timestamp; defaults to now.' })
  @IsOptional()
  @IsISO8601()
  occurredAt?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  note?: string;
}
