[BUG]: default property values is not taking in account when required
GillianPerard opened this issue · 0 comments
GillianPerard commented
Version
5.1.0
Description
When I declare a JsonObject
, with some JsonProperty
s required
, if a default value is set but the property is missing from the object to deserialize, it returns an error while the property is properly set with the default value.
Error
Fail to deserialize: Property 'bar' is required in Foo {}.
Reproduction
import { JsonObject, JsonProperty, JsonSerializer } from "typescript-json-serializer";
@JsonObject()
class Foo {
@JsonProperty({required: true})
bar: string = 'bar';
}
const serializer = new JsonSerializer();
const foo = {};
console.log(serializer.deserializeObject(foo, Foo))
On which OS the bug appears?
Windows 11
What is your project type?
NodeJs
On which build mode the bug appears?
Both
Anything else?
No response