AFTAB ALAM MANSOORI
17 hours ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
30 additions and
6 deletions
-
apps/api/src/services/import/import-data.dto.spec.ts
-
libs/common/src/lib/dtos/create-asset-profile.dto.ts
-
libs/common/src/lib/dtos/create-order.dto.ts
-
libs/common/src/lib/dtos/update-order.dto.ts
|
|
|
@ -34,6 +34,30 @@ describe('ImportDataDto', () => { |
|
|
|
).resolves.toBeInstanceOf(ImportDataDto); |
|
|
|
}); |
|
|
|
|
|
|
|
it('accepts an activity with an all-numeric symbol and transforms it to a string', async () => { |
|
|
|
const importData = loadImportData('ok', 'sample.json'); |
|
|
|
(importData.activities[0] as any).symbol = 639; |
|
|
|
|
|
|
|
const result = (await validationPipe.transform(importData, { |
|
|
|
metatype: ImportDataDto, |
|
|
|
type: 'body' |
|
|
|
})) as ImportDataDto; |
|
|
|
|
|
|
|
expect(result.activities[0].symbol).toBe('639'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('accepts an asset profile with an all-numeric symbol and transforms it to a string', async () => { |
|
|
|
const importData = loadImportData('ok', 'sample.json'); |
|
|
|
(importData.assetProfiles[0] as any).symbol = 639; |
|
|
|
|
|
|
|
const result = (await validationPipe.transform(importData, { |
|
|
|
metatype: ImportDataDto, |
|
|
|
type: 'body' |
|
|
|
})) as ImportDataDto; |
|
|
|
|
|
|
|
expect(result.assetProfiles[0].symbol).toBe('639'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('refuses a comment of an account balance which exceeds the maximum length', async () => { |
|
|
|
const importData = loadImportData('ok', 'sample.json'); |
|
|
|
|
|
|
|
|
|
|
|
@ -22,7 +22,7 @@ import { |
|
|
|
MaxLength, |
|
|
|
ValidateNested |
|
|
|
} from 'class-validator'; |
|
|
|
import { isString } from 'lodash-es'; |
|
|
|
import { isNumber, isString } from 'lodash-es'; |
|
|
|
|
|
|
|
import { CountryDto } from './country.dto'; |
|
|
|
import { HoldingDto } from './holding.dto'; |
|
|
|
@ -98,7 +98,7 @@ export class CreateAssetProfileDto { |
|
|
|
@IsString() |
|
|
|
@MaxLength(SYMBOL_MAXIMUM_LENGTH) |
|
|
|
@Transform(({ value }: TransformFnParams) => |
|
|
|
isString(value) ? value.trim() : value |
|
|
|
isNumber(value) ? `${value}` : (isString(value) ? value.trim() : value) |
|
|
|
) |
|
|
|
symbol: string; |
|
|
|
|
|
|
|
|
|
|
|
@ -26,7 +26,7 @@ import { |
|
|
|
Min, |
|
|
|
Validate |
|
|
|
} from 'class-validator'; |
|
|
|
import { isString } from 'lodash-es'; |
|
|
|
import { isNumber, isString } from 'lodash-es'; |
|
|
|
|
|
|
|
export class CreateOrderDto { |
|
|
|
@IsOptional() |
|
|
|
@ -76,7 +76,7 @@ export class CreateOrderDto { |
|
|
|
@IsString() |
|
|
|
@MaxLength(SYMBOL_MAXIMUM_LENGTH) |
|
|
|
@Transform(({ value }: TransformFnParams) => |
|
|
|
isString(value) ? value.trim() : value |
|
|
|
isNumber(value) ? `${value}` : (isString(value) ? value.trim() : value) |
|
|
|
) |
|
|
|
symbol: string; |
|
|
|
|
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ import { |
|
|
|
Min, |
|
|
|
Validate |
|
|
|
} from 'class-validator'; |
|
|
|
import { isString } from 'lodash-es'; |
|
|
|
import { isNumber, isString } from 'lodash-es'; |
|
|
|
|
|
|
|
export class UpdateOrderDto { |
|
|
|
@IsOptional() |
|
|
|
@ -77,7 +77,7 @@ export class UpdateOrderDto { |
|
|
|
@IsString() |
|
|
|
@MaxLength(SYMBOL_MAXIMUM_LENGTH) |
|
|
|
@Transform(({ value }: TransformFnParams) => |
|
|
|
isString(value) ? value.trim() : value |
|
|
|
isNumber(value) ? `${value}` : (isString(value) ? value.trim() : value) |
|
|
|
) |
|
|
|
symbol: string; |
|
|
|
|
|
|
|
|