src/lanes/dto/create-lane.dto.ts
Properties |
|
| destName |
Type : string
|
Decorators :
@ApiProperty({example: 'Mombasa'})
|
|
Defined in src/lanes/dto/create-lane.dto.ts:35
|
| Optional destZoneId |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/lanes/dto/create-lane.dto.ts:40
|
| distanceKm |
Type : number
|
Decorators :
@ApiProperty({example: 480, description: 'Lane distance in km (must be > 0)'})
|
|
Defined in src/lanes/dto/create-lane.dto.ts:49
|
| Optional estimatedHours |
Type : number
|
Decorators :
@ApiPropertyOptional({example: 8.5, description: 'Estimated drive time in hours'})
|
|
Defined in src/lanes/dto/create-lane.dto.ts:57
|
| name |
Type : string
|
Decorators :
@ApiProperty({example: 'Nairobi - Mombasa'})
|
|
Defined in src/lanes/dto/create-lane.dto.ts:18
|
| originName |
Type : string
|
Decorators :
@ApiProperty({example: 'Nairobi'})
|
|
Defined in src/lanes/dto/create-lane.dto.ts:24
|
| Optional originZoneId |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/lanes/dto/create-lane.dto.ts:29
|
import {
IsNotEmpty,
IsString,
IsOptional,
IsNumber,
IsPositive,
Max,
MaxLength,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class CreateLaneDto {
@ApiProperty({ example: 'Nairobi - Mombasa' })
@IsString()
@IsNotEmpty()
@MaxLength(120)
name: string;
@ApiProperty({ example: 'Nairobi' })
@IsString()
@IsNotEmpty()
@MaxLength(120)
originName: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
originZoneId?: string;
@ApiProperty({ example: 'Mombasa' })
@IsString()
@IsNotEmpty()
@MaxLength(120)
destName: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
destZoneId?: string;
// Distance must be > 0 — hard cap at 20,000 km (longer than any
// earthly route, prevents typos like 480000 from poisoning ETAs).
@ApiProperty({ example: 480, description: 'Lane distance in km (must be > 0)' })
@Type(() => Number)
@IsNumber({ maxDecimalPlaces: 2 })
@IsPositive({ message: 'distanceKm must be greater than 0' })
@Max(20000, { message: 'distanceKm must be 20000 or less' })
distanceKm: number;
@ApiPropertyOptional({ example: 8.5, description: 'Estimated drive time in hours' })
@IsOptional()
@Type(() => Number)
@IsNumber({ maxDecimalPlaces: 2 })
@IsPositive({ message: 'estimatedHours must be greater than 0' })
@Max(720, { message: 'estimatedHours must be 720 (30 days) or less' })
estimatedHours?: number;
}