Skip to content

HttpQuery validator expression in first argument leaks to other parameters #614

@marcj

Description

@marcj
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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions