Boolean parameter in request body is always true in NestJS api

Found a workaround for the issue with class-transformer You can use this: @IsBoolean() @Transform(({ value} ) => value === ‘true’) public laserMode: boolean; This will transform the string into a boolean value, based on if it is ‘true’ or any other string. A simple workaround, but every string different than true, results in false.

validate nested objects using class-validator in nest.js controller

Try specifying the nested type with @Type: import { Type } from ‘class-transformer’; export class CurrencyDTO { @ValidateNested({ each: true }) @Type(() => Data) data: Data[]; } For a nested type to be validated, it needs to be an instance of a class not just a plain data object. With the @Type decorator you tell … Read more

Password confirmation in TypeScript with `class-validator`

Finally I managed to solve the password matching problem thanks to the suggestion of @ChristopheGeers in the comments of my question: @piero: It’s not supported yet as mentioned. But here’s an example decorator (@IsLongerThan): LINK …. it checks if a property is longer than another one. So it’s possible to compare one property against another. … Read more

Validate nested objects using class validator and nestjs

for me, I would able to validate nested object with ‘class-transformer’ import { Type } from ‘class-transformer’; full example: 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 … Read more

Class-validator – validate array of objects

Add @Type(() => AuthParam) to your array and it should be working. Type decorator is required for nested objects(arrays). Your code becomes import { IsArray, ValidateNested, ArrayMinSize, ArrayMaxSize } from ‘class-validator’; import { AuthParam } from ‘./authParam.model’; import { Type } from ‘class-transformer’; export class SignInModel { @IsArray() @ValidateNested({ each: true }) @ArrayMinSize(2) @ArrayMaxSize(2) @Type(() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)