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