title: Cannot cast boolean query parameter to actual boolean value Nest.js
body: <p>In my API I have created endpoint that allows to get users from database with pagination:</p>
  <pre><code>@Get()
  findByQuery(
    @Query() { skip, take, count }: QueryDto
  ): Promise&lt;User[] | { rows: User[]; count: number }&gt; {
    return this.userService.findByQuery(skip, take, count);
  }
  </code></pre>
  <p>In <code>QueryDto</code> using <code>class-validator</code> I've made validator for values and using <code>class-transformer</code> parser for those values, cause, from query, by default, they are just strings.</p>
  <pre><code>import { Transform } from 'class-transformer';
  import { IsBoolean, IsNumber, IsOptional } from 'class-validator';
  
  export class QueryDto {
    @Transform(({ value }) =&gt; parseInt(value))
    @IsNumber()
    skip: number;
  
    @Transform(({ value }) =&gt; parseInt(value))
    @IsNumber()
    take: number;
  
    @Transform(({ value }) =&gt; {
      return value === 'true';
    })
    @IsOptional()
    @IsBoolean()
    count?: boolean;
  }
  </code></pre>
  <p>And here is the problem, this last validator for <code>count</code> field just doesn't work. In service it's still just string.</p>
  <p>So, for example, if I do request like this - <code>http://localhost:3000/api/user?skip=1&amp;take=1&amp;count=false</code> - fields <code>skip</code> and <code>take</code> are parsed to numbers correctly, but <code>count</code> is always string.</p>
  <p>How can I fix this?</p>
  <p><strong>PS.</strong></p>
  <p>Also, I have created custom validation pipe, and I am now sure, if problem can be here:</p>
  <pre><code>import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';
  import { plainToInstance } from 'class-transformer';
  import { validate } from 'class-validator';
  import { ValidationException } from '../exception/validation.exception';
  
  @Injectable()
  export class ValidationPipe implements PipeTransform&lt;any&gt; {
    async transform(value: any, metadata: ArgumentMetadata): Promise&lt;any&gt; {
      const obj = plainToInstance(metadata.metatype, value);
      const errors = await validate(obj);
  
      if (errors.length) {
        const messages = errors.map((err) =&gt; {
          return {
            [err.property]: `${Object.values(err.constraints).join(', ')}`
          };
        });
        throw new ValidationException({ errors: messages });
      }
      return value;
    }
  }
  </code></pre>