Files
edr-platform/apps/edr-freight-api/src/modules/rule-engine/dto/create-weight-limit-rule.dto.ts
2026-07-04 01:11:23 +00:00

36 lines
1.1 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsIn, IsNumber, IsOptional, IsUUID, Min } from 'class-validator';
const TRADE_DIRECTIONS = ['IMPORT', 'EXPORT', 'BOTH', 'DOMESTIC'] as const;
export class CreateWeightLimitRuleDto {
@ApiProperty({ description: 'FK to container_types.id' })
@IsUUID()
containerTypeId!: string;
@ApiProperty({
enum: TRADE_DIRECTIONS,
description: 'Trade direction: IMPORT, EXPORT, BOTH, or DOMESTIC',
})
@IsIn([...TRADE_DIRECTIONS])
tradeDirection!: string;
@ApiProperty({ description: 'Maximum allowed VGM in tons', minimum: 0 })
@IsNumber()
@Min(0)
@Transform(({ value }) => Number(value))
maxVgmTons!: number;
@ApiPropertyOptional({
description:
'Hard per-unit weight ceiling in tons — above this the booking cannot be created. Null/omitted = no ceiling.',
minimum: 0,
})
@IsOptional()
@IsNumber()
@Min(0)
@Transform(({ value }) => (value === null || value === undefined || value === '' ? null : Number(value)))
maxCapacityTons?: number | null;
}