Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/simplify data source checks in DTOs (#4581)

Thomas Kaul50e7e3d3c786
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac62bb06c8..ffa35cf41f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Simplified the data source check in the DTO of the activity creation
+- Simplified the data source check in the DTO of the asset profile update
- Renamed `User` to `user` in the `Subscription` database schema
- Migrated the `@ghostfolio/ui/assistant` component to control flow
- Migrated the `@ghostfolio/ui/value` component to control flow
diff --git a/apps/api/src/app/admin/update-asset-profile.dto.ts b/apps/api/src/app/admin/update-asset-profile.dto.ts
index 45923410ab..5056dccdbf 100644
--- a/apps/api/src/app/admin/update-asset-profile.dto.ts
+++ b/apps/api/src/app/admin/update-asset-profile.dto.ts
@@ -32,7 +32,7 @@ export class UpdateAssetProfileDto {
@IsOptional()
currency?: string;
- @IsEnum(DataSource, { each: true })
+ @IsEnum(DataSource)
@IsOptional()
dataSource?: DataSource;
diff --git a/apps/api/src/app/order/create-order.dto.ts b/apps/api/src/app/order/create-order.dto.ts
index f40e65ba1e..c2b10fd810 100644
--- a/apps/api/src/app/order/create-order.dto.ts
+++ b/apps/api/src/app/order/create-order.dto.ts
@@ -49,7 +49,7 @@ export class CreateOrderDto {
@IsOptional()
customCurrency?: string;
- @IsEnum(DataSource, { each: true })
+ @IsEnum(DataSource)
@IsOptional()
dataSource?: DataSource;
diff --git a/test/import/invalid-data-source.json b/test/import/invalid-data-source.json
new file mode 100644
index 0000000000..472e295ee0
--- /dev/null
+++ b/test/import/invalid-data-source.json
@@ -0,0 +1,18 @@
+{
+ "meta": {
+ "date": "2021-01-01T00:00:00.000Z",
+ "version": "dev"
+ },
+ "activities": [
+ {
+ "currency": "USD",
+ "dataSource": "<invalid>",
+ "date": "2021-01-01T00:00:00.000Z",
+ "fee": 0,
+ "quantity": 20,
+ "symbol": "AAPL",
+ "type": "BUY",
+ "unitPrice": 100.0
+ }
+ ]
+}