Open
Description
I think plainToClass
should always reutrn a class-instance or throw an exception.
Here's a simple example where this is not the case (using version 0.2.3
):
class Test {
@IsString()
readonly table!: string;
}
// note, that we call it with a completely wrong type: string instead of JSON-object
const result = plainToClass(Test, 'not a class');
Then result
is of type string
(value = 'not a class'
).
I'd expect plainToClass
to:
- return an instance of type
Test
where all properties remain undefined, or - throw an exception
Not sure, if this is a bug or intended - maybe there's a good reason for the current behaviour that I am missing?
see also Stackoverflow Question