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!

Added data validation

Yevhenii Kulisidid2f0e31e84e7
diff --git a/src/project/dto/add-subscriber.dto.ts b/src/project/dto/add-subscriber.dto.ts
index c52c81d4b..f98405485 100644
--- a/src/project/dto/add-subscriber.dto.ts
+++ b/src/project/dto/add-subscriber.dto.ts
@@ -1,7 +1,11 @@
+import { Matches, IsEmail } from 'class-validator'
+
export class AddSubscriberParamsDto {
+ @Matches(/^(?!.*--)[a-zA-Z0-9-]{12}$/)
readonly projectId: string
}
export class AddSubscriberBodyDto {
+ @IsEmail()
readonly email: string
}
diff --git a/src/project/dto/get-subscribers.dto.ts b/src/project/dto/get-subscribers.dto.ts
index 07ce80ba9..c097f5b0a 100644
--- a/src/project/dto/get-subscribers.dto.ts
+++ b/src/project/dto/get-subscribers.dto.ts
@@ -1,8 +1,16 @@
+import { IsNumberString, IsOptional, Matches } from 'class-validator'
+
export class GetSubscribersParamsDto {
+ @Matches(/^(?!.*--)[a-zA-Z0-9-]{12}$/)
readonly projectId: string
}
export class GetSubscribersQueriesDto {
+ @IsOptional()
+ @IsNumberString()
readonly offset?: string
+
+ @IsOptional()
+ @IsNumberString()
readonly limit?: string
}
diff --git a/src/project/dto/remove-subscriber.dto.ts b/src/project/dto/remove-subscriber.dto.ts
index d2bc8898f..d09b4d880 100644
--- a/src/project/dto/remove-subscriber.dto.ts
+++ b/src/project/dto/remove-subscriber.dto.ts
@@ -1,4 +1,9 @@
+import { Matches, IsUUID } from 'class-validator'
+
export class RemoveSubscriberParamsDto {
+ @Matches(/^(?!.*--)[a-zA-Z0-9-]{12}$/)
readonly projectId: string
+
+ @IsUUID('4')
readonly subscriberId: string
}