Skip to content

Using class-validator with @QueryParams #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mlarsson opened this issue Nov 8, 2017 · 2 comments
Closed

Using class-validator with @QueryParams #323

mlarsson opened this issue Nov 8, 2017 · 2 comments

Comments

@mlarsson
Copy link

mlarsson commented Nov 8, 2017

I have the following and are using v. 0.7.6 of routing-controllers:

export class TestObject {

  @IsNumber()
  @IsPositive()
  someNumber: number;

  @IsString()
  @IsNotEmpty()
  someString: string;

}

@Controller('/v1/test')
export class PaymentController {

  @Get()
  getTest( @QueryParams() test: TestObject) {
    console.log(test);
    return 'ok';
  }
}

I would expect that a url like "v1/test?someNumber=notanumber" would cause the user to get a bad request 400 response (as "notanumber" is not a positive number and as "someString" is missing) or at least cause some kind of error somewhere. But nothing happens. The request goes through, the object will be printed and 200 is returned.

Am I missing something here?

Kind regards Morten

@MichalLytek
Copy link
Contributor

@QueryParams() validation and normalization will be supported in next major release:
#315
#289

Please reopen this issue if after release it still won't work correctly.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants