typestack / class-transformer

Decorator-based transformation, serialization, and deserialization between objects and classes.
MIT License
6.81k stars 500 forks source link

Add support for parsing boolean strings #1686

Open sandratatarevicova opened 7 months ago

sandratatarevicova commented 7 months ago

Description

class-transformer is often used in NestJS projects to parse request bodies/params. The current version transforms the string 'false' to true and requires ugly workarounds to make it work as expected, see #626, https://stackoverflow.com/questions/59046629/boolean-parameter-in-request-body-is-always-true-in-nestjs-api an the other linked issues.

This PR adds configuration option parseBooleanStrings, which allows parsing boolean strings. It is disabled by default so that it does not break existing projects.

Checklist

Fixes

fixes #626 fixes #2170 fixes #306