mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
ArrayMinSize,
|
|
IsArray,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
Matches,
|
|
MaxLength,
|
|
} from 'class-validator';
|
|
|
|
export class BuildTrainDto {
|
|
@ApiProperty({ example: '8001', description: 'EXPORT run number (odd, unique across trains)' })
|
|
@IsString()
|
|
@MaxLength(20)
|
|
@Matches(/^\d*[13579]$/, {
|
|
message: 'Export train number must be numeric and odd (e.g. 8001)',
|
|
})
|
|
exportTrainNumber!: string;
|
|
|
|
@ApiProperty({ example: '8002', description: 'IMPORT run number (even, unique across trains)' })
|
|
@IsString()
|
|
@MaxLength(20)
|
|
@Matches(/^\d*[02468]$/, {
|
|
message: 'Import train number must be numeric and even (e.g. 8002)',
|
|
})
|
|
importTrainNumber!: string;
|
|
|
|
@ApiProperty({ format: 'uuid', description: 'Yard the train is built in' })
|
|
@IsUUID()
|
|
currentYardId!: string;
|
|
|
|
@ApiProperty({
|
|
type: [String],
|
|
format: 'uuid',
|
|
description: 'Locomotives pulling the train (minimum 1), in consist order',
|
|
})
|
|
@IsArray()
|
|
@ArrayMinSize(1, { message: 'A train must be pulled by at least one locomotive' })
|
|
@IsUUID('all', { each: true })
|
|
locomotiveIds!: string[];
|
|
|
|
@ApiPropertyOptional({
|
|
type: [String],
|
|
format: 'uuid',
|
|
description: 'Wagons to attach at build time, in consist order (must sit in the same yard)',
|
|
})
|
|
@IsOptional()
|
|
@IsArray()
|
|
@IsUUID('all', { each: true })
|
|
wagonIds?: string[];
|
|
|
|
@ApiProperty({ maxLength: 100, description: 'Vogue number' })
|
|
@IsString()
|
|
@IsNotEmpty({ message: 'Vogue number is required' })
|
|
@MaxLength(100)
|
|
trainName!: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
notes?: string;
|
|
}
|