Skip to content

Commit

Permalink
fix(common): when transforming invalid boolean values
Browse files Browse the repository at this point in the history
on `ValidationPipe`, it must not return a valid boolean
  • Loading branch information
micalevisk committed Jan 26, 2023
1 parent bcf4bf9 commit 43bb6c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/common/pipes/validation.pipe.ts
Expand Up @@ -179,6 +179,11 @@ export class ValidationPipe implements PipeTransform<any> {
return value;
}
if (metatype === Boolean) {
if (typeof value === 'undefined') {
// This is an workaround to deal with optional boolean values as
// the default value of an optional boolean shouldn't be a boolean
return undefined;
}
return value === true || value === 'true';
}
if (metatype === Number) {
Expand Down

0 comments on commit 43bb6c2

Please sign in to comment.