File

src/lanes/dto/create-lane.dto.ts

Index

Properties

Properties

destName
Type : string
Decorators :
@ApiProperty({example: 'Mombasa'})
@IsString()
@IsNotEmpty()
@MaxLength(120)
Optional destZoneId
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
distanceKm
Type : number
Decorators :
@ApiProperty({example: 480, description: 'Lane distance in km (must be > 0)'})
@Type(undefined)
@IsNumber({maxDecimalPlaces: 2})
@IsPositive({message: 'distanceKm must be greater than 0'})
@Max(20000, {message: 'distanceKm must be 20000 or less'})
Optional estimatedHours
Type : number
Decorators :
@ApiPropertyOptional({example: 8.5, description: 'Estimated drive time in hours'})
@IsOptional()
@Type(undefined)
@IsNumber({maxDecimalPlaces: 2})
@IsPositive({message: 'estimatedHours must be greater than 0'})
@Max(720, {message: 'estimatedHours must be 720 (30 days) or less'})
name
Type : string
Decorators :
@ApiProperty({example: 'Nairobi - Mombasa'})
@IsString()
@IsNotEmpty()
@MaxLength(120)
originName
Type : string
Decorators :
@ApiProperty({example: 'Nairobi'})
@IsString()
@IsNotEmpty()
@MaxLength(120)
Optional originZoneId
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
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;
}

results matching ""

    No results matching ""