Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

better validation

Blue Mousec032d7ec1ad0
diff --git a/backend/apps/cloud/src/project/dto/project.dto.ts b/backend/apps/cloud/src/project/dto/project.dto.ts
index 1bdf7a94d..56dc64d0a 100644
--- a/backend/apps/cloud/src/project/dto/project.dto.ts
+++ b/backend/apps/cloud/src/project/dto/project.dto.ts
@@ -7,6 +7,7 @@ import {
IsArray,
IsUrl,
MaxLength,
+ ValidateIf,
} from 'class-validator'
import { BotsProtectionLevel } from '../entity/project.entity'
@@ -82,6 +83,7 @@ export class ProjectDTO {
'Optional website URL. Used to display favicon and construct clickable page links.',
})
@IsOptional()
+ @ValidateIf(o => o.websiteUrl !== null && o.websiteUrl !== undefined)
@IsUrl({}, { message: 'websiteUrl must be a valid URL' })
@MaxLength(512)
websiteUrl?: string | null
diff --git a/backend/apps/cloud/src/project/dto/update-project.dto.ts b/backend/apps/cloud/src/project/dto/update-project.dto.ts
index 5f34600d7..f9e019015 100644
--- a/backend/apps/cloud/src/project/dto/update-project.dto.ts
+++ b/backend/apps/cloud/src/project/dto/update-project.dto.ts
@@ -35,13 +35,13 @@ export class UpdateProjectDto extends IntersectionType(
@ApiProperty({
required: false,
description:
- 'CAPTCHA PoW difficulty (number of leading zeros required). Higher = harder. Range: 1-6.',
+ 'CAPTCHA PoW difficulty (number of leading zeros required). Higher = harder. Range: 2-6.',
default: 4,
- minimum: 1,
+ minimum: 2,
maximum: 6,
})
@IsInt()
- @Min(1)
+ @Min(2)
@Max(6)
@IsOptional()
captchaDifficulty?: number