Complete the code to validate that the 'email' property is a valid email address.
import { [1] } from 'class-validator'; class UserDto { @[1]() email: string; }
The @IsEmail() decorator checks if the property is a valid email address.
Complete the code to ensure the 'age' property is a number and at least 18.
import { IsNumber, [1] } from 'class-validator'; class UserDto { @IsNumber() @[1](18) age: number; }
The @Min(18) decorator ensures the number is at least 18.
Fix the error in the code to validate that 'username' is a non-empty string.
import { IsString, [1] } from 'class-validator'; class UserDto { @IsString() @[1]() username: string; }
The @IsNotEmpty() decorator ensures the string is not empty.
Fill both blanks to validate that 'password' is a string with minimum length 8.
import { [1], [2] } from 'class-validator'; class UserDto { @[1]() @[2](8) password: string; }
@IsString() ensures the value is a string, and @MinLength(8) ensures it has at least 8 characters.
Fill all three blanks to create a validation that 'tags' is an optional array of strings with each string not empty.
import { [1], [2], [3] } from 'class-validator'; class UserDto { @[1]() @[2]({ each: true }) @[3]({ each: true }) tags?: string[]; }
@IsOptional() allows the property to be missing, @IsString({ each: true }) checks each item is a string, and @IsNotEmpty({ each: true }) ensures no empty strings in the array.