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.
49 lines
642 B
TypeScript
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[];
|
|
}
|