Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

class-validator validate nested object

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;
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript extend interface 
Typescript :: socket.io typescript 
Typescript :: angular jasmine mock http request 
Typescript :: angular append array to another 
Typescript :: Pip install requirements txt not found 
Typescript :: typescript array of objects interface 
Typescript :: array with multiple types in ts 
Typescript :: loc multiple conditions string and integer 
Typescript :: how to check if there is any point which lies inside the circle 
Typescript :: an attempt was made to access a socket in a way forbidden by its access permissions 
Typescript :: how many alphabets in english 
Typescript :: actionscript 
Typescript :: Do not use BuildContexts across async gaps. 
Typescript :: how ro execute typescript file 
Typescript :: add correct host key in /root/.ssh/known_hosts to get rid of this message 
Typescript :: remove wordpress products all at once 
Typescript :: typescript string to number 
Typescript :: angular formgroup validate manually 
Typescript :: create custom properties for user firebase 
Typescript :: typescript export async function 
Typescript :: access single document with its id flutter 
Typescript :: Already included file name react tsconfig 
Typescript :: nest js parseint pipe 
Typescript :: write a script that prints hello world followed by a new line to the standard output in linux 
Typescript :: typescript pass a function as an argunetn 
Typescript :: typescript convert string to character array 
Typescript :: how to read temp file in windowsnodejs 
Typescript :: angular animation done event type typescript 
Typescript :: typeorm decrement 
Typescript :: How can I call a method every x seconds? 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =