deepkit / deepkit-framework

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

Wrong error message when validations in union member fail #577

Open i-am-ian opened 5 months ago

i-am-ian commented 5 months ago

Hi,

First I just want to say that I really appreciate all the work that's being put into deepkit, I'm really enjoying it.

I recently came across an issue (I'm using deepkit/type 1.0.1-alpha.151):

class MyClass {
    code!: (string & MinLength<1> & MaxLength<2>) | null;
}

When validation of code fails due to specifying an empty string or a string with length > 2 I correctly get a validation error. However, the error message I get is No valid union member found. Valid: string | null.

Instead, I would expect to receive either Min length is 1 or Max length is 2.