File

src/clients/dto/create-client.dto.ts

Index

Properties

Properties

Optional address
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(300)
Optional city
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
Optional classRef
Type : string
Decorators :
@ApiPropertyOptional({example: 'single_trip'})
@IsOptional()
@IsString()
@MaxLength(40)
code
Type : string
Decorators :
@ApiProperty({example: 'ACME', 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( => )

Short uppercase identifier — unique within the org. Auto-uppercased by class-transformer so admins can type lowercase without surprise.

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'})
Optional country
Type : string
Decorators :
@ApiPropertyOptional({example: 'Kenya'})
@IsOptional()
@IsString()
@MaxLength(80)
Optional county
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
Optional description
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(500)
Optional latitude
Type : number
Decorators :
@ApiPropertyOptional({example: undefined, description: 'Latitude in degrees, -90 to 90'})
@IsOptional()
@Type(undefined)
@IsNumber()
@Min(undefined)
@Max(90)
Optional longitude
Type : number
Decorators :
@ApiPropertyOptional({example: 36.817223, description: 'Longitude in degrees, -180 to 180'})
@IsOptional()
@Type(undefined)
@IsNumber()
@Min(undefined)
@Max(180)
name
Type : string
Decorators :
@ApiProperty({example: 'Acme Corporation'})
@IsString()
@IsNotEmpty()
@MaxLength(120)
Optional region
Type : string
Decorators :
@ApiPropertyOptional({example: 'Coast'})
@IsOptional()
@IsString()
@MaxLength(80)
Optional state
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
Optional suburb
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
Optional zipCode
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(20)
import {
  IsNotEmpty,
  IsString,
  IsOptional,
  IsNumber,
  IsEmail,
  Min,
  Max,
  Matches,
  MaxLength,
} from 'class-validator';
import { Type, Transform } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateClientDto {
  @ApiProperty({ example: 'Acme Corporation' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(120)
  name: string;

  /**
   * Short uppercase identifier — unique within the org. Auto-uppercased
   * by class-transformer so admins can type lowercase without surprise.
   */
  @ApiProperty({ example: 'ACME', 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(500)
  description?: 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;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(300)
  address?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(80)
  suburb?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(80)
  city?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(80)
  county?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(80)
  state?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(20)
  zipCode?: string;

  @ApiPropertyOptional({ example: 'Kenya' })
  @IsOptional()
  @IsString()
  @MaxLength(80)
  country?: string;

  @ApiPropertyOptional({ example: 'Coast' })
  @IsOptional()
  @IsString()
  @MaxLength(80)
  region?: string;

  @ApiPropertyOptional({ example: 'single_trip' })
  @IsOptional()
  @IsString()
  @MaxLength(40)
  classRef?: string;

  @ApiPropertyOptional({ example: -1.286389, description: 'Latitude in degrees, -90 to 90' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(-90)
  @Max(90)
  latitude?: number;

  @ApiPropertyOptional({ example: 36.817223, description: 'Longitude in degrees, -180 to 180' })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(-180)
  @Max(180)
  longitude?: number;
}

results matching ""

    No results matching ""