Skip to content

Commit

Permalink
Fix: create issue dto (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
saimanoj authored Sep 15, 2024
1 parent 39c7f82 commit 35c3f71
Showing 1 changed file with 2 additions and 42 deletions.
44 changes: 2 additions & 42 deletions packages/types/src/issue/create-issue.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
IsObject,
IsOptional,
IsString,
ValidateBy,
ValidateNested,
ValidationArguments,
} from 'class-validator';

import { CreateIssueRelationDto } from '../issue-relation';
Expand All @@ -28,49 +26,11 @@ export class CreateIssueDto {
title: string;

@IsString()
@ValidateBy(
{
name: 'eitherDescriptionOrDescriptionMarkdown',
validator: {
validate: (_value: string, args: ValidationArguments): boolean => {
const object = args.object as CreateIssueDto;
const { description, descriptionMarkdown } = object;
return !!(
(description && descriptionMarkdown) ||
description ||
descriptionMarkdown
);
},
},
},
{
message:
'Either description or descriptionMarkdown must be provided, but not both',
},
)
@IsOptional()
description?: string;

@IsString()
@ValidateBy(
{
name: 'eitherDescriptionOrDescriptionMarkdown',
validator: {
validate: (_value: string, args: ValidationArguments): boolean => {
const object = args.object as CreateIssueDto;
const { description, descriptionMarkdown } = object;
return !!(
(description && descriptionMarkdown) ||
description ||
descriptionMarkdown
);
},
},
},
{
message:
'Either description or descriptionMarkdown must be provided, but not both',
},
)
@IsOptional()
descriptionMarkdown?: string;

@IsOptional()
Expand Down

0 comments on commit 35c3f71

Please sign in to comment.