Files
memegoat/backend/src/contents/dto/create-content.dto.ts
Mathis HERRIOT 5671ba60a6 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.
2026-01-14 20:41:45 +01:00

49 lines
642 B
TypeScript

import {
IsArray,
IsEnum,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
IsUUID,
MaxLength,
} from "class-validator";
export enum ContentType {
MEME = "meme",
GIF = "gif",
}
export class CreateContentDto {
@IsEnum(ContentType)
type!: "meme" | "gif";
@IsString()
@IsNotEmpty()
@MaxLength(255)
title!: string;
@IsString()
@IsNotEmpty()
@MaxLength(512)
storageKey!: string;
@IsString()
@IsNotEmpty()
@MaxLength(128)
mimeType!: string;
@IsInt()
fileSize!: number;
@IsOptional()
@IsUUID()
categoryId?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
@MaxLength(64, { each: true })
tags?: string[];
}