feat(dto): enforce field length constraints across DTOs

Add `@MaxLength` validations to limit string field lengths in multiple DTOs, ensuring consistent data validation and integrity. Integrate `CreateApiKeyDto` in the API keys controller for improved type safety.
This commit is contained in:
Mathis HERRIOT
2026-01-14 20:41:45 +01:00
parent 5f2672021e
commit 5671ba60a6
7 changed files with 34 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ import {
IsOptional,
IsString,
IsUUID,
MaxLength,
} from "class-validator";
export enum ContentType {
@@ -19,14 +20,17 @@ export class CreateContentDto {
@IsString()
@IsNotEmpty()
@MaxLength(255)
title!: string;
@IsString()
@IsNotEmpty()
@MaxLength(512)
storageKey!: string;
@IsString()
@IsNotEmpty()
@MaxLength(128)
mimeType!: string;
@IsInt()
@@ -39,5 +43,6 @@ export class CreateContentDto {
@IsOptional()
@IsArray()
@IsString({ each: true })
@MaxLength(64, { each: true })
tags?: string[];
}

View File

@@ -4,6 +4,7 @@ import {
IsOptional,
IsString,
IsUUID,
MaxLength,
} from "class-validator";
import { ContentType } from "./create-content.dto";
@@ -13,6 +14,7 @@ export class UploadContentDto {
@IsString()
@IsNotEmpty()
@MaxLength(255)
title!: string;
@IsOptional()
@@ -20,6 +22,8 @@ export class UploadContentDto {
categoryId?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
@MaxLength(64, { each: true })
tags?: string[];
}