From f1f4f6247ddb41ef84f95a10a68b61a378934411 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:08:37 +0200 Subject: [PATCH] Feature/validate url in create and update platform dto (#3235) * Validate url * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/platform/create-platform.dto.ts | 7 +++++-- apps/api/src/app/platform/update-platform.dto.ts | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b8c35b2..6484b691f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support to override the asset sub class of an asset profile in the asset profile details dialog of the admin control - Added support to override the url of an asset profile in the asset profile details dialog of the admin control +### Changed + +- Improved the url validation in the create and update platform endpoint + ## 2.70.0 - 2024-04-02 ### Added diff --git a/apps/api/src/app/platform/create-platform.dto.ts b/apps/api/src/app/platform/create-platform.dto.ts index a61f21743..941354c11 100644 --- a/apps/api/src/app/platform/create-platform.dto.ts +++ b/apps/api/src/app/platform/create-platform.dto.ts @@ -1,9 +1,12 @@ -import { IsString } from 'class-validator'; +import { IsString, IsUrl } from 'class-validator'; export class CreatePlatformDto { @IsString() name: string; - @IsString() + @IsUrl({ + protocols: ['https'], + require_protocol: true + }) url: string; } diff --git a/apps/api/src/app/platform/update-platform.dto.ts b/apps/api/src/app/platform/update-platform.dto.ts index ec6f2687c..4c4f907af 100644 --- a/apps/api/src/app/platform/update-platform.dto.ts +++ b/apps/api/src/app/platform/update-platform.dto.ts @@ -1,4 +1,4 @@ -import { IsString } from 'class-validator'; +import { IsString, IsUrl } from 'class-validator'; export class UpdatePlatformDto { @IsString() @@ -7,6 +7,9 @@ export class UpdatePlatformDto { @IsString() name: string; - @IsString() + @IsUrl({ + protocols: ['https'], + require_protocol: true + }) url: string; }