I'm writing a REST API and I have a route defined as follows:
router.get("/objects/:id?/:val1?/:val2?", getObject);
I'm sending the following get request from Postman:
http://localhost:8000/objects?val1=5&val2=6
I'm using express validator like this in getObject:
req.check("val1", "Invalid param: val1").notEmpty().isInt();
Even though I'm passing in numbers, when I it's only picking them up as strings. When I print to console using JSON.stringify(req.query), they also show as string instead of numbers. How would I go about fixing this? Would I have to cast the parameters as numbers? If I did, express validator wouldn't be as useful since it could only check for whether the parameter was passed in.