mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Harden validation of accounts, assetClasses, dataSource and tags in endpoints with filters * Update changelogpull/6845/merge
committed by
GitHub
6 changed files with 43 additions and 22 deletions
@ -1,23 +1,35 @@ |
|||
import { IsOptional, IsString } from 'class-validator'; |
|||
import { AssetClass, DataSource } from '@prisma/client'; |
|||
import { Transform, TransformFnParams } from 'class-transformer'; |
|||
import { IsEnum, IsOptional, IsString, IsUUID } from 'class-validator'; |
|||
import { isString } from 'lodash'; |
|||
|
|||
export class FilterDto { |
|||
@IsOptional() |
|||
@IsString() |
|||
accounts?: string; |
|||
@IsUUID(undefined, { each: true }) |
|||
@Transform(({ value }: TransformFnParams) => { |
|||
return isString(value) ? value.split(',') : value; |
|||
}) |
|||
accounts?: string[]; |
|||
|
|||
@IsEnum(AssetClass, { each: true }) |
|||
@IsOptional() |
|||
@IsString() |
|||
assetClasses?: string; |
|||
@Transform(({ value }: TransformFnParams) => { |
|||
return isString(value) ? value.split(',') : value; |
|||
}) |
|||
assetClasses?: AssetClass[]; |
|||
|
|||
@IsEnum(DataSource) |
|||
@IsOptional() |
|||
@IsString() |
|||
dataSource?: string; |
|||
dataSource?: DataSource; |
|||
|
|||
@IsOptional() |
|||
@IsString() |
|||
symbol?: string; |
|||
|
|||
@IsOptional() |
|||
@IsString() |
|||
tags?: string; |
|||
@IsUUID(undefined, { each: true }) |
|||
@Transform(({ value }: TransformFnParams) => { |
|||
return isString(value) ? value.split(',') : value; |
|||
}) |
|||
tags?: string[]; |
|||
} |
|||
|
|||
Loading…
Reference in new issue