deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

HttpQuery validator expression in first argument leaks to other parameters

Open marcj opened this issue 4 months ago • 1 comments


test('query validator withing HttpQuery', async () => {
    class Controller {
        @http.GET('do')
        async do(
            a: HttpQuery<string & MinLength<8>>,
            b: HttpQuery<string>,
        ) {
            return { valid: true };
        }
    }

    const httpKernel = createHttpKernel([Controller]);
    expect((await httpKernel.request(HttpRequest.GET('/do').query('a=aaaaaaaa&b=bbbb'))).json).toMatchObject({
        valid: true
    });
});

this should work, but fails since b parameter also gets the MinLength<8> validator attached. Error:

message": "Validation error:
b(minLength): Min length is 8 caused by value "bbbb"

marcj avatar Sep 25 '24 19:09 marcj