Klassenvalidator validieren verschachteltes Objekt
import {
MinLength,
MaxLength,
IsNotEmpty,
ValidateNested,
IsDefined,
IsNotEmptyObject,
IsObject,
IsString,
} from 'class-validator';
import { Type } from 'class-transformer';
class MultiLanguageDTO {
@IsString()
@IsNotEmpty()
@MinLength(4)
@MaxLength(40)
en: string;
@IsString()
@IsNotEmpty()
@MinLength(4)
@MaxLength(40)
ar: string;
}
export class VideoDTO {
@IsDefined()
@IsNotEmptyObject()
@IsObject()
@ValidateNested()
@Type(() => MultiLanguageDTO)
name!: MultiLanguageDTO;
}
DevPedrada