File

src/zones/dto/create-zone.dto.ts

Index

Properties

Properties

code
Type : string
Decorators :
@ApiProperty({example: 'NBO', description: '2-12 chars, A-Z 0-9 _ only'})
@IsString()
@IsNotEmpty()
@MaxLength(12)
@Matches(/^[A-Z0-9_]{2,12}$/, {message: 'code must be 2-12 uppercase letters, digits, or underscores'})
@Transform( => )

Short uppercase identifier — must be unique within the org. Stored as uppercase regardless of how the user typed it. Restricted to letters/digits/underscore so URL-safe and predictable in joins.

Optional description
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(500)
name
Type : string
Decorators :
@ApiProperty({example: 'Nairobi Metro'})
@IsString()
@IsNotEmpty()
@MaxLength(80)
Optional region
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
@MaxLength(80)
import {
  IsNotEmpty,
  IsString,
  IsOptional,
  Matches,
  MaxLength,
} from 'class-validator';
import { Transform } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateZoneDto {
  @ApiProperty({ example: 'Nairobi Metro' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(80)
  name: string;

  /**
   * Short uppercase identifier — must be unique within the org. Stored
   * as uppercase regardless of how the user typed it. Restricted to
   * letters/digits/underscore so URL-safe and predictable in joins.
   */
  @ApiProperty({ example: 'NBO', description: '2-12 chars, A-Z 0-9 _ only' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(12)
  @Matches(/^[A-Z0-9_]{2,12}$/, {
    message: 'code must be 2-12 uppercase letters, digits, or underscores',
  })
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toUpperCase() : value))
  code: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  @MaxLength(500)
  description?: string;

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

results matching ""

    No results matching ""