- 
                Notifications
    You must be signed in to change notification settings 
- Fork 518
Closed as not planned
Closed as not planned
Copy link
Labels
status: duplicateIssue is being tracked already in another issue.Issue is being tracked already in another issue.type: featureIssues related to new features.Issues related to new features.
Description
Description
If we try to convert a value that has typeof string, then in some cases it returns the wrong value. e.g value: 'true' will return true, while on the other hand value: 'false' will also return the true.
Minimal code-snippet showcasing the problem
Consideration: A network access request.
import { Expose, plainToInstance } from 'class-transformer';
class RoleDTO {
  @Expose()
    id: number
  @Expose()
  canAccess: boolean
}
plainToInstance(RoleDTO, { id: 1, canAccess: 'true' }, { enableImplicitConversion: true })
plainToInstance(RoleDTO, { id: 2, canAccess: 'false' }, { enableImplicitConversion: true })Expected behavior
RoleDTO with the id:1 should have canAccess: true and  RoleDTO with the id:2 should have canAccess: false
Actual behavior
RoleDTO with id 1, and 2 have canAccess: true
This is a common JS Boolean conversion issue, I will be submitting a PR for this.
ivashog, Oloompa, mjsilva, laszlo-horvath and juand-vjuand-v
Metadata
Metadata
Assignees
Labels
status: duplicateIssue is being tracked already in another issue.Issue is being tracked already in another issue.type: featureIssues related to new features.Issues related to new features.