diff --git a/CHANGELOG.md b/CHANGELOG.md index 536453dbf..30cd0b206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgraded `stripe` from version `20.4.1` to `21.0.1` +### Fixed + +- Fixed the asset profile validation to allow saving with an empty URL field + ## 3.1.0 - 2026-04-29 ### Added diff --git a/libs/common/src/lib/dtos/create-asset-profile.dto.ts b/libs/common/src/lib/dtos/create-asset-profile.dto.ts index 85ad73cc0..eb7c59b20 100644 --- a/libs/common/src/lib/dtos/create-asset-profile.dto.ts +++ b/libs/common/src/lib/dtos/create-asset-profile.dto.ts @@ -1,6 +1,7 @@ import { IsCurrencyCode } from '@ghostfolio/common/validators/is-currency-code'; import { AssetClass, AssetSubClass, DataSource, Prisma } from '@prisma/client'; +import { Transform, TransformFnParams } from 'class-transformer'; import { IsArray, IsBoolean, @@ -9,6 +10,7 @@ import { IsString, IsUrl } from 'class-validator'; +import { isString } from 'lodash'; export class CreateAssetProfileDto { @IsEnum(AssetClass, { each: true }) @@ -77,5 +79,8 @@ export class CreateAssetProfileDto { protocols: ['https'], require_protocol: true }) + @Transform(({ value }: TransformFnParams) => + isString(value) && value.trim() === '' ? undefined : value + ) url?: string; } diff --git a/libs/common/src/lib/dtos/update-asset-profile.dto.ts b/libs/common/src/lib/dtos/update-asset-profile.dto.ts index 43f5aa617..5a86d5485 100644 --- a/libs/common/src/lib/dtos/update-asset-profile.dto.ts +++ b/libs/common/src/lib/dtos/update-asset-profile.dto.ts @@ -1,6 +1,7 @@ import { IsCurrencyCode } from '@ghostfolio/common/validators/is-currency-code'; import { AssetClass, AssetSubClass, DataSource, Prisma } from '@prisma/client'; +import { Transform, TransformFnParams } from 'class-transformer'; import { IsArray, IsBoolean, @@ -10,6 +11,7 @@ import { IsString, IsUrl } from 'class-validator'; +import { isString } from 'lodash'; export class UpdateAssetProfileDto { @IsEnum(AssetClass, { each: true }) @@ -67,5 +69,8 @@ export class UpdateAssetProfileDto { protocols: ['https'], require_protocol: true }) + @Transform(({ value }: TransformFnParams) => + isString(value) && value.trim() === '' ? undefined : value + ) url?: string; }