| 1 | import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; |
| 2 | import { |
| 3 | IsBoolean, |
| 4 | IsOptional, |
| 5 | IsString, |
| 6 | Matches, |
| 7 | MaxLength, |
| 8 | MinLength, |
| 9 | ValidateIf, |
| 10 | } from 'class-validator'; |
| 11 | |
| 12 | const REF_PATTERN = / |
| 13 | |
| 14 | export class CreatePullRequestRequestDTO |
| 15 | @ApiProperty({ example |
| 16 | @IsString() |
| 17 | @MinLength(1) |
| 18 | @MaxLength(200) |
| 19 | title: string; |
| 20 | |
| 21 | @ApiPropertyOptional() |
| 22 | @IsString() |
| 23 | @IsOptional() |
| 24 | @MaxLength(20000) |
| 25 | body?: string |
| 26 | |
| 27 | @ApiProperty({ |
| 28 | description: 'Branch to merge into, in this repository.', |
| 29 | example: 'main', |
| 30 | }) |
| 31 | @IsString() |
| 32 | @Matches(REF_PATTERN) |
| 33 | base: string; |
| 34 | |
| 35 | @ApiProperty({ |
| 36 | description: |
| 37 | 'Branch to merge from. `owner:branch` for a fork, or a bare branch name for this repository.', |
| 38 | example: 'alice:feature', |
| 39 | }) |
| 40 | @IsString() |
| 41 | @Matches(/^[ |
| 42 | head: string; |
| 43 | |
| 44 | @ApiPropertyOptional({ default |
| 45 | @IsBoolean() |
| 46 | @IsOptional() |
| 47 | draft?: boolean |
| 48 | } |
| 49 | |
| 50 | export class UpdatePullRequestRequestDTO |
| 51 | @ApiPropertyOptional({ example |
| 52 | @IsString() |
| 53 | @IsOptional() |
| 54 | @MinLength(1) |
| 55 | @MaxLength(200) |
| 56 | title?: string |
| 57 | |
| 58 | @ApiPropertyOptional({ |
| 59 | type: String, |
| 60 | nullable: true, |
| 61 | description: 'Markdown. `null` clears the description.', |
| 62 | }) |
| 63 | @IsString() |
| 64 | @IsOptional() |
| 65 | @ValidateIf((_ |
| 66 | @MaxLength(20000) |
| 67 | body?: string |
| 68 | } |