lets say you have an interface like this:
import { Get, QueryParam } from 'routing-controllers';
// ...
@Get('/students')
async getStudents(
@QueryParam('count') count?: number,
): Promise<void> {
console.log(count);
}
How do you ensure count is an int and not a float, for example? Something like this is not valid:
@IsInt() @QueryParam('count') count?: number,
IsInt can only be used on a class property, eg for a body model, not for a single parameter value. But according to. this https://github.com/typestack/routing-controllers#auto-validating-action-params it is possible:
This technique works not only with @Body but also with @Param, @QueryParam, @BodyParam and other decorators.