-
Notifications
You must be signed in to change notification settings - Fork 520
Closed
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
version: "class-transformer": "0.2.3"
example:
import 'reflect-metadata';
import { Expose, plainToClass } from 'class-transformer';
class TestClass {
@Expose()
prop: boolean;
}
console.log(plainToClass(TestClass, {
prop: 'false',
}, {
enableImplicitConversion: true,
}));
returned: TestClass { prop: true }
expected: TestClass { prop: false }
proposal:
if value === 'true' || value === true || value === 1 || value === '1'
then true
otherwise false
somethink like ths:
import { Transform } from 'class-transformer';
export function ToBoolean(): (target: any, key: string) => void {
return Transform((value: any) => value === 'true' || value === true || value === 1 || value === '1');
}
joeloudjinz, leepood, DzmitryU, karam94, danieloprado and 10 morejoeloudjinz
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.