【发布时间】:2021-11-17 05:17:58
【问题描述】:
如何处理表单数据中数字数组的验证? 因为我传递的是表单数据格式的数据,所以我无法验证数字数组实际上,我不知道该怎么做。
这是我的 CreatePostDto:
export class CreatePostDto {
@IsNotEmpty()
@IsString()
@MinLength(3)
title: string;
@ApiProperty({ type: 'string', format: 'binary' })
thumbnail: any;
@IsNotEmpty()
@IsString()
@MinLength(20)
@MaxLength(300)
description: string;
@IsNotEmpty()
@IsString()
@MinLength(20)
body: string;
@IsOptional()
@Type(() => Number)
@IsNumberString({}, { each: true })
tags: number[];
@IsOptional()
@Type(() => Number)
@IsNumberString({}, { each: true })
categories: number[];
@IsBooleanString()
published: boolean;
}
【问题讨论】:
标签: node.js express validation nestjs class-variables