import { ArrayMaxSize, ArrayMinSize, ArrayUnique, IsArray, Matches } from 'class-validator';

/** Containers loaded onto a truck at Truck_dispatch (after arrival, before it leaves). */
export class LoadCustomerTruckDto {
  @IsArray()
  @ArrayMinSize(1)
  // A truck carries at most 2 containers (two 20ft, or one 40ft).
  @ArrayMaxSize(2)
  @ArrayUnique()
  @Matches(/^[A-Z]{4}\d{7}$/, {
    each: true,
    message: 'each container number must match ISO container format, e.g. ABCD1234567',
  })
  containerNumbers!: string[];
}
