File

src/people/dtos/request/create-person.dto.ts

Description

Data Transfer Object for creating a new person. This DTO is used to validate the input data when creating a new person. It includes properties such as name in Persian and English,

Index

Properties

Properties

birthDate
Type : Date | null
Decorators :
@ApiProperty({description: 'The birth date of the person', example: '1963-06-09', type: String, nullable: true})
@IsString()
@IsOptional()

The birth date of the person. This property is optional and can be null.

Example :
birthPlace
Type : string | null
Decorators :
@ApiProperty({description: 'The birthplace of the person', example: 'Owensboro, Kentucky, USA', type: String, nullable: true})
@IsString()
@IsOptional()

The birthplace of the person. This property is optional and can be null.

Example :
deathDate
Type : Date | null
Decorators :
@ApiProperty({description: 'The death date of the person', example: '2023-10-01', type: String, nullable: true})
@IsString()
@IsOptional()

The death date of the person. This property is optional and can be null.

Example :
imageUrl
Type : ConfirmUploadRequestDto | null
Decorators :
@ApiProperty({description: 'profile photo URL for the person', example: undefined, required: false, nullable: true, type: ConfirmUploadRequestDto})
@ValidateNested()
@Type(undefined)

The URL of the person's image. This property is optional and can be null.

Example :
nameEn
Type : string
Decorators :
@ApiProperty({description: 'The name of the person in English', example: 'Johnny Depp'})
@IsString()
@IsNotEmpty()

The name of the person in English. This property is required and must be a non-empty string.

Example :
nameFa
Type : string
Decorators :
@ApiProperty({description: 'The name of the person in Persian', example: 'جانی دپ'})
@IsString()
@IsNotEmpty()

The name of the person in Persian. This property is required and must be a non-empty string.

Example :
slug
Type : string
Decorators :
@ApiProperty({description: 'A unique slug for the person', example: 'johnny-depp'})
@IsString()
@IsNotEmpty()

A unique slug for the person. This property is required and must be a non-empty string.

Example :
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';
import { ConfirmUploadRequestDto } from 'src/upload-center/dtos/request/confirm-upload.dto';
import { BufferBucketNames } from 'src/upload-center/enums/bucket-names.enum';

/**
 * Data Transfer Object for creating a new person.
 * This DTO is used to validate the input data when creating a new person.
 * It includes properties such as name in Persian and English,
 */
export class CreatePersonRequestDto {
  /**
   * The name of the person in Persian.
   * This property is required and must be a non-empty string.
   * @example 'جانی دپ'
   */
  @ApiProperty({
    description: 'The name of the person in Persian',
    example: 'جانی دپ',
  })
  @IsString()
  @IsNotEmpty()
  nameFa: string;

  /**
   * The name of the person in English.
   * This property is required and must be a non-empty string.
   * @example 'Johnny Depp'
   */
  @ApiProperty({
    description: 'The name of the person in English',
    example: 'Johnny Depp',
  })
  @IsString()
  @IsNotEmpty()
  nameEn: string;

  /**
   * A unique slug for the person.
   * This property is required and must be a non-empty string.
   * @example 'johnny-depp'
   */
  @ApiProperty({
    description: 'A unique slug for the person',
    example: 'johnny-depp',
  })
  @IsString()
  @IsNotEmpty()
  slug: string;

  /**
   * The birth date of the person.
   * This property is optional and can be null.
   * @example '1963-06-09'
   */
  @ApiProperty({
    description: 'The birth date of the person',
    example: '1963-06-09',
    type: String,
    nullable: true,
  })
  @IsString()
  @IsOptional()
  birthDate: Date | null;

  /**
   * The death date of the person.
   * This property is optional and can be null.
   * @example '2023-10-01'
   */
  @ApiProperty({
    description: 'The death date of the person',
    example: '2023-10-01',
    type: String,
    nullable: true,
  })
  @IsString()
  @IsOptional()
  deathDate: Date | null;

  /**
   * The birthplace of the person.
   * This property is optional and can be null.
   * @example 'Owensboro, Kentucky, USA'
   */
  @ApiProperty({
    description: 'The birthplace of the person',
    example: 'Owensboro, Kentucky, USA',
    type: String,
    nullable: true,
  })
  @IsString()
  @IsOptional()
  birthPlace: string | null;

  /**
   * The URL of the person's image.
   * This property is optional and can be null.
   * @example 'https://example.com/image.jpg'
   */
  @ApiProperty({
    description: 'profile photo URL for the person',
    example: {
      bucket: BufferBucketNames.PROFILE,
      key: 'profile-file-key',
    },
    required: false,
    nullable: true,
    type: ConfirmUploadRequestDto,
  })
  @ValidateNested()
  @Type(() => ConfirmUploadRequestDto)
  imageUrl: ConfirmUploadRequestDto | null;
}

results matching ""

    No results matching ""