Browse Source

Task/improve symbol validation of create asset profile DTO (#8013)

Improve symbol validation
pull/7550/merge
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
f987e4160e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      libs/common/src/lib/dtos/create-asset-profile.dto.ts

8
libs/common/src/lib/dtos/create-asset-profile.dto.ts

@ -10,17 +10,19 @@ import {
DataSource DataSource
} from '@ghostfolio/prisma/enums'; } from '@ghostfolio/prisma/enums';
import { Type } from 'class-transformer'; import { Transform, TransformFnParams, Type } from 'class-transformer';
import { import {
IsArray, IsArray,
IsBoolean, IsBoolean,
IsEnum, IsEnum,
IsNotEmpty,
IsOptional, IsOptional,
IsString, IsString,
IsUrl, IsUrl,
MaxLength, MaxLength,
ValidateNested ValidateNested
} from 'class-validator'; } from 'class-validator';
import { isString } from 'lodash-es';
import { CountryDto } from './country.dto'; import { CountryDto } from './country.dto';
import { HoldingDto } from './holding.dto'; import { HoldingDto } from './holding.dto';
@ -92,8 +94,12 @@ export class CreateAssetProfileDto {
@ValidateNested({ each: true }) @ValidateNested({ each: true })
sectors?: Prisma.InputJsonArray; sectors?: Prisma.InputJsonArray;
@IsNotEmpty()
@IsString() @IsString()
@MaxLength(SYMBOL_MAXIMUM_LENGTH) @MaxLength(SYMBOL_MAXIMUM_LENGTH)
@Transform(({ value }: TransformFnParams) =>
isString(value) ? value.trim() : value
)
symbol: string; symbol: string;
@IsOptional() @IsOptional()

Loading…
Cancel
Save