Enhance boolean conversion logic for strings and numeric values
Description
This update improves the boolean conversion logic when handling string values in the type mapping. The changes include:
- Converting strings representing numbers (e.g., '1', '0') to booleans.
- Handling specific string values like 'true' and 'false' to map them to their correct boolean counterparts.
This ensures more consistent and accurate conversions when dealing with strings that are either numeric or represent boolean values.
Checklist
- [x] the pull request title describes what this PR does (not a vague title like
Update index.md) - [x] the pull request targets the default branch of the repository (
develop) - [x] the code follows the established code style of the repository
-
npm run prettier:checkpasses -
npm run lint:checkpasses
-
- [x] tests are added for the changes I made (if any source code was modified)
- [ ] documentation added or updated
- [x] I have run the project locally and verified that there are no errors
Fixes
fixes #676, fixes #626
This fix ensures that query parameters sent as strings, which are common in NestJS, are correctly converted to booleans when using class-transformer. It prevents incorrect boolean conversions that previously resulted in all such values being interpreted as true. For exemple have '1', '0', 'true', 'false' result to having true.
Hi @typestack,
I would like to know if there's anything missing for my PR to be approved.
Thank you!
Very interesting, might be very useful :+1:
Is there something that can block my Pr ?