routing-controllers
routing-controllers copied to clipboard
Custom param decorator with required set to true does not throw an error if value is undefined
function RejectAlways(){
return createParamDecorator({
required: true,
value: action =>{
}
})
}
@JsonController()
export class TestController
{
@Get("/test")
public async GetTest(@RejectAlways() someValue:String){
return {status:"All good chief"};
}
}
Sending a GET request to /test
results in {status:"All good chief"}
. Shouldn't this throw an error?
action with return undefined
doesn't work, either.
Using 0.8.1. Typescript 3.8.3.
createParamDecorator
example in readme says:
here you'll have user authorized and you can safely save your question in the case if user returned your undefined from the database and "required"parameter was set, routing-controllers will throw you ParameterRequired error
Just FYI in case anyone comes across this issue, the bug definitely still exists today. Do not rely on the required
parameter to make a custom parameter required!