Browse Source

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 <noreply@anthropic.com>
pull/7508/head
Miguel Rocha 4 weeks ago
parent
commit
53f393a79b
  1. 6
      CHANGELOG.md
  2. 6
      libs/common/src/lib/dtos/update-asset-profile.dto.ts

6
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/), 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). 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 ## 3.39.0 - 2026-08-01
### Changed ### Changed

6
libs/common/src/lib/dtos/update-asset-profile.dto.ts

@ -7,7 +7,7 @@ import {
DataSource, DataSource,
Prisma Prisma
} from '@prisma/client'; } from '@prisma/client';
import { Type } from 'class-transformer'; import { Transform, TransformFnParams, Type } from 'class-transformer';
import { import {
IsArray, IsArray,
IsBoolean, IsBoolean,
@ -18,6 +18,7 @@ import {
IsUrl, IsUrl,
ValidateNested ValidateNested
} from 'class-validator'; } from 'class-validator';
import { isString } from 'lodash';
import { CountryDto } from './country.dto'; import { CountryDto } from './country.dto';
import { HoldingDto } from './holding.dto'; import { HoldingDto } from './holding.dto';
@ -96,5 +97,8 @@ export class UpdateAssetProfileDto {
protocols: ['http', 'https'], protocols: ['http', 'https'],
require_protocol: true require_protocol: true
}) })
@Transform(({ value }: TransformFnParams) =>
isString(value) && value.trim() === '' ? undefined : value
)
url?: string; url?: string;
} }

Loading…
Cancel
Save