deepkit / deepkit-framework

A new full-featured and high-performance TypeScript framework
https://deepkit.io/
MIT License
3.24k stars 123 forks source link

@deepkit/type deserialize() doesn't throw in a wrapper #616

Open f3oall opened 4 weeks ago

f3oall commented 4 weeks ago

When I use a wrapper function, ValidationError is not thrown when properties are missing.

Created a repo with reproduction: https://github.com/f3oall/deepkit-deserialization

Run bun test, all tests should pass (but they don't). See comments in the test file for additional info.

f3oall commented 4 weeks ago

Might got it wrong, should deserialize() throw an error if there's missing required properties?

marcj commented 3 weeks ago

deserialize does not do any validation. use cast which does deserialize + validation https://github.com/deepkit/deepkit-framework/blob/ab96f2f3c0f7f795692d49e6a37ee5194647a9c1/packages/type/src/serializer-facade.ts#L26