Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

refactor(template): reuse the shared NUL-character validator

Yudhi Armyndharise2f0bc2ad0d6
diff --git a/src/modules/template/dto/template.dto.ts b/src/modules/template/dto/template.dto.ts
index 1fa1f748b..47f086ed1 100644
--- a/src/modules/template/dto/template.dto.ts
+++ b/src/modules/template/dto/template.dto.ts
@@ -1,14 +1,12 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
-import { IsString, IsNotEmpty, IsOptional, MaxLength, NotContains, ValidateIf } from 'class-validator';
+import { IsString, IsNotEmpty, IsOptional, MaxLength, ValidateIf } from 'class-validator';
import { MaxCodePoints } from '../../../common/validation/max-code-points';
+import { NoNulCharacter } from '../../../common/validation/no-nul-character';
const NAME_MAX_LENGTH = 100;
const BODY_MAX_LENGTH = 4096;
const HEADER_FOOTER_MAX_LENGTH = 1024;
-// PostgreSQL text and varchar columns cannot store U+0000, so the write would fail as a 500.
-const NoNulCharacter = () => NotContains('\u0000', { message: '$property must not contain a NUL character' });
-
export class CreateTemplateDto {
@ApiProperty({
description: 'Unique template name within the session',