From 53f393a79ba2e259cfa9c69a1bb296ef4649049a Mon Sep 17 00:00:00 2001 From: Miguel Rocha Date: Sat, 1 Aug 2026 17:59:56 +0100 Subject: [PATCH] Fix validation of empty url in asset profile dialog The url attribute in the asset profile dialog of the admin control panel is optional, but leaving it empty made the form fail with "url must be a URL address". The form initializes the control with an empty string, which is not skipped by IsOptional, since it only applies to null and undefined. Transform empty strings to undefined in the DTO so the validation treats the attribute as absent. Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 6 ++++++ libs/common/src/lib/dtos/update-asset-profile.dto.ts | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b31046e8cd..97f9f003d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed the validation of an empty url in the asset profile dialog of the admin control panel + ## 3.39.0 - 2026-08-01 ### Changed 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 a6e2230e8e..35a4025a8b 100644 --- a/libs/common/src/lib/dtos/update-asset-profile.dto.ts +++ b/libs/common/src/lib/dtos/update-asset-profile.dto.ts @@ -7,7 +7,7 @@ import { DataSource, Prisma } from '@prisma/client'; -import { Type } from 'class-transformer'; +import { Transform, TransformFnParams, Type } from 'class-transformer'; import { IsArray, IsBoolean, @@ -18,6 +18,7 @@ import { IsUrl, ValidateNested } from 'class-validator'; +import { isString } from 'lodash'; import { CountryDto } from './country.dto'; import { HoldingDto } from './holding.dto'; @@ -96,5 +97,8 @@ export class UpdateAssetProfileDto { protocols: ['http', 'https'], require_protocol: true }) + @Transform(({ value }: TransformFnParams) => + isString(value) && value.trim() === '' ? undefined : value + ) url?: string; }