import { IsIn, IsNotEmpty, IsString, Matches, MaxLength } from 'class-validator';

export const CUSTOMER_TRUCK_TYPES = [
  'Flatbed',
  'Container Chassis',
  'Lowboy',
  'Box Truck',
  'Tipper',
] as const;

export class CustomerTruckAssignmentDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(32)
  truckPlateNumber!: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(120)
  driverName!: string;

  @IsString()
  @IsNotEmpty()
  @IsIn(CUSTOMER_TRUCK_TYPES)
  truckType!: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(16)
  @Matches(/^[A-Z]{4}\d{7}$/, {
    message: 'containerNumberToLoad must match ISO container format, e.g. ABCD1234567',
  })
  containerNumberToLoad!: string;
}
