From 1370ad3dd70a5d0995d8446298d503d4b262c59a Mon Sep 17 00:00:00 2001 From: Pavel Strunkin Date: Wed, 19 May 2021 15:26:30 +0300 Subject: [PATCH] Multipart endpoint could not parse ignoreAreas #268 Closes https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker/issues/268 --- src/test-runs/dto/create-test-request.dto.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test-runs/dto/create-test-request.dto.ts b/src/test-runs/dto/create-test-request.dto.ts index 6b9cf6d8..fa4b016e 100644 --- a/src/test-runs/dto/create-test-request.dto.ts +++ b/src/test-runs/dto/create-test-request.dto.ts @@ -1,6 +1,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsOptional, IsUUID, IsNumber, IsBoolean } from 'class-validator'; +import { isArray } from 'lodash'; import { BaselineDataDto } from '../../shared/dto/baseline-data.dto'; import { IgnoreAreaDto } from './ignore-area.dto'; @@ -36,5 +37,11 @@ export class CreateTestRequestDto extends BaselineDataDto { @ApiPropertyOptional({ type: [IgnoreAreaDto] }) @IsOptional() + @Transform((it) => { + if (isArray(it)) { + return it; + } + return JSON.parse(it); + }) ignoreAreas?: IgnoreAreaDto[]; }