File

src/transporters/dto/create-transporter.dto.ts

Index

Properties

Properties

code
Type : string
Decorators :
@ApiProperty({example: 'KTL', description: '2-20 chars, A-Z 0-9 _ - only'})
@IsString()
@IsNotEmpty()
@MaxLength(20)
@Matches(/^[A-Z0-9_-]{2,20}$/, {message: 'code must be 2-20 uppercase letters, digits, underscore, or hyphen'})
@Transform( => )
Optional contactEmail
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsEmail()
@MaxLength(120)
Optional contactName
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(120)
Optional contactPhone
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(30)
@Matches(/^\+?[0-9 ()\-]{7,}$/, {message: 'contactPhone must be 7+ digits, optionally with +, spaces, dashes, or parentheses'})
name
Type : string
Decorators :
@ApiProperty({example: 'KenTruck Logistics'})
@IsString()
@IsNotEmpty()
@MaxLength(120)
import {
  IsNotEmpty,
  IsString,
  IsOptional,
  IsEmail,
  Matches,
  MaxLength,
} from 'class-validator';
import { Transform } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateTransporterDto {
  @ApiProperty({ example: 'KenTruck Logistics' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(120)
  name: string;

  @ApiProperty({ example: 'KTL', description: '2-20 chars, A-Z 0-9 _ - only' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(20)
  @Matches(/^[A-Z0-9_-]{2,20}$/, {
    message: 'code must be 2-20 uppercase letters, digits, underscore, or hyphen',
  })
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toUpperCase() : value))
  code: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(120)
  contactName?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsEmail()
  @MaxLength(120)
  contactEmail?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(30)
  @Matches(/^\+?[0-9 ()\-]{7,}$/, {
    message: 'contactPhone must be 7+ digits, optionally with +, spaces, dashes, or parentheses',
  })
  contactPhone?: string;
}

results matching ""

    No results matching ""