class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

fix: @IsBoolean` alway transforms the value of a boolean query param to `true`

Open SLSJL opened this issue 2 years ago • 0 comments

Description

@IsBoolean alway transforms the value of a boolean query param to true even if the transformOptions.enableImplicitConversion.true is set as true

Definition of a boolean query parameter is as below.

Minimal code-snippet showcasing the problem

  @IsBoolean()
  @IsOptional()
  @Transform((object) => {
    console.log(object);
    return object.value;
  })
  isMuted?: boolean;

Expected behavior

// For query param value as  'true'
{
value: true,
key: 'isMuted',
object: {isMuted: 'true', ...}
...
}
{
value: false,
key: 'isMuted',
object: {isMuted: 'fale', ...}
...
}

Actual behavior

image

SLSJL avatar Jul 21 '23 09:07 SLSJL