Open
Description
Description
@Transform()
is not being called for properties with undefined
values if exposeDefaultValues
set to true
.
While this may be intentional behaviour, I do not think that this is correct, since not every property of a class can define a default value.
Minimal code-snippet showcasing the problem
export class Example {
propertyA: string;
@Transform(({ value }) => {
console.log('propertyB is:', value);
return value;
})
propertyB?: string;
}
plainToInstance(Example, { propertyA: 'value' });
// > propertyB is: undefined
plainToInstance(Example, { propertyA: 'value' }, { exposeDefaultValues: true });
// no console.log
Expected behavior
In my opinion, transformation must be called always in this case.
Actual behavior
See Description