Closed as not planned
Closed as not planned
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.