| 1 | import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; |
| 2 | import { Transform } |
| 3 | import { |
| 4 | ArrayMaxSize, |
| 5 | IsArray, |
| 6 | IsOptional, |
| 7 | IsString, |
| 8 | MaxLength, |
| 9 | MinLength, |
| 10 | ValidateIf, |
| 11 | } from 'class-validator'; |
| 12 | |
| 13 | export class CreateIssueRequestDTO |
| 14 | @ApiProperty({ example |
| 15 | @IsString() |
| 16 | @Transform(({ |
| 17 | @MinLength(1) |
| 18 | @MaxLength(200) |
| 19 | title: string; |
| 20 | |
| 21 | @ApiPropertyOptional({ description |
| 22 | @IsString() |
| 23 | @IsOptional() |
| 24 | @MaxLength(20000) |
| 25 | body?: string |
| 26 | |
| 27 | @ApiPropertyOptional({ |
| 28 | description: 'Label names in this repository.', |
| 29 | example: ['bug'], |
| 30 | }) |
| 31 | @IsArray() |
| 32 | @IsString({ each |
| 33 | @ArrayMaxSize(20) |
| 34 | @IsOptional() |
| 35 | labels?: string |
| 36 | |
| 37 | @ApiPropertyOptional({ |
| 38 | description: 'Usernames to assign.', |
| 39 | example: ['octocat'], |
| 40 | }) |
| 41 | @IsArray() |
| 42 | @IsString({ each |
| 43 | @ArrayMaxSize(10) |
| 44 | @IsOptional() |
| 45 | assignees?: string |
| 46 | } |
| 47 | |
| 48 | export class UpdateIssueRequestDTO |
| 49 | @ApiPropertyOptional({ example |
| 50 | @IsString() |
| 51 | @IsOptional() |
| 52 | @Transform(({ |
| 53 | @MinLength(1) |
| 54 | @MaxLength(200) |
| 55 | title?: string |
| 56 | |
| 57 | @ApiPropertyOptional({ |
| 58 | type: String, |
| 59 | nullable: true, |
| 60 | description: 'Markdown. `null` clears the description.', |
| 61 | }) |
| 62 | @IsString() |
| 63 | @IsOptional() |
| 64 | @ValidateIf((_ |
| 65 | @MaxLength(20000) |
| 66 | body?: string |
| 67 | } |