Closed as not planned
Description
I was trying to...
Parse an NestJs http request params to a filter class but the property I'm filtering is a boolean which is always being converted to true.
The problem:
Nest will parse the query params to an object whose properties keys are the same passed to the browser but the values are all converted to strings. So the object taken by class-transformer
is something like this:
URL: http://example.com/?clt=something
{
"clt": "something"
}
And I need to convert this stringified object to my filter class:
import { IsBoolean } from 'class-validator';
import { Expose, Type } from 'class-transformer';
export class EmployeeFilter {
@Expose()
@IsBoolean()
@Type(() => Boolean)
clt?: boolean
}
If I pass false to the url, the parsed object still with clt=true
Am I missing something?
Doc: https://github.com/typestack/class-transformer#working-with-nested-objects
Codesandbox https://codesandbox.io/s/nestjs-forked-4x3qd?file=/src/validation.pipe.ts