src/vehicles/dto/create-vehicle.dto.ts
Properties |
|
| Optional description |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:134
|
| Optional driverId |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:106
|
| Optional fuelType |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:89
|
| Optional homeSite |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:122
|
| Optional licensePlate |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:67
|
| Optional make |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:34
|
| Optional maxVolume |
Type : number
|
Decorators :
@ApiPropertyOptional({description: 'Max cargo volume in m³'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:83
|
| Optional maxWeight |
Type : number
|
Decorators :
@ApiPropertyOptional({description: 'Max payload weight in kg'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:75
|
| Optional model |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:40
|
| Optional name |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:128
|
| Optional securityGroup |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:140
|
| Optional telematicsId |
Type : string
|
Decorators :
@ApiPropertyOptional({description: 'Provider-side device ID for GPS pairing'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:101
|
| Optional telematicsProvider |
Type : string
|
Decorators :
@ApiPropertyOptional({example: 'mix_telematics'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:95
|
| Optional transporterId |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:116
|
| type |
Type : VehicleType
|
Decorators :
@ApiProperty({enum: VehicleType})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:28
|
| unitNumber |
Type : string
|
Decorators :
@ApiProperty({example: 'TRK-001'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:24
|
| Optional vehicleClassId |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:111
|
| Optional vin |
Type : string
|
Decorators :
@ApiPropertyOptional({example: '1HGCM82633A123456'})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:61
|
|
Vehicle Identification Number — strict 17-character alphanumeric per ISO 3779. The DB has a UNIQUE constraint on this column so duplicates 500 here instead of leaking the constraint name in the error. |
| Optional year |
Type : number
|
Decorators :
@ApiPropertyOptional({example: 2022})
|
|
Defined in src/vehicles/dto/create-vehicle.dto.ts:48
|
import {
IsNotEmpty,
IsString,
IsOptional,
IsEnum,
IsNumber,
IsPositive,
Matches,
Max,
Min,
MaxLength,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { VehicleType } from '@prisma/client';
const CURRENT_YEAR = new Date().getFullYear();
export class CreateVehicleDto {
@ApiProperty({ example: 'TRK-001' })
@IsString()
@IsNotEmpty()
@MaxLength(40)
unitNumber: string;
@ApiProperty({ enum: VehicleType })
@IsEnum(VehicleType)
type: VehicleType;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(60)
make?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(60)
model?: string;
@ApiPropertyOptional({ example: 2022 })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(1980)
@Max(CURRENT_YEAR + 1)
year?: number;
/**
* Vehicle Identification Number — strict 17-character alphanumeric per
* ISO 3779. The DB has a UNIQUE constraint on this column so duplicates
* 500 here instead of leaking the constraint name in the error.
*/
@ApiPropertyOptional({ example: '1HGCM82633A123456' })
@IsOptional()
@IsString()
@Matches(/^[A-HJ-NPR-Z0-9]{17}$/, {
message: 'vin must be exactly 17 characters (no I, O, or Q)',
})
vin?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(20)
licensePlate?: string;
@ApiPropertyOptional({ description: 'Max payload weight in kg' })
@IsOptional()
@Type(() => Number)
@IsNumber()
@IsPositive()
@Max(200_000)
maxWeight?: number;
@ApiPropertyOptional({ description: 'Max cargo volume in m³' })
@IsOptional()
@Type(() => Number)
@IsNumber()
@IsPositive()
@Max(500)
maxVolume?: number;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(40)
fuelType?: string;
@ApiPropertyOptional({ example: 'mix_telematics' })
@IsOptional()
@IsString()
@MaxLength(40)
telematicsProvider?: string;
@ApiPropertyOptional({ description: 'Provider-side device ID for GPS pairing' })
@IsOptional()
@IsString()
@MaxLength(80)
telematicsId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
driverId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
vehicleClassId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
transporterId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(120)
homeSite?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
name?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(60)
securityGroup?: string;
}