Genie Discord forum
![Author Avatar](https://cdn.discordapp.com/avatars/217063427242328066/7925f152a0bf7c71e85bbbd09df4fbfa.png?size=512)
I have a route
route(/users/:users_id::Int, get_user, method=GET)
and I'm wondering if I have to input sanitize/ double check that the payload(:users_id)
that I get within the get_user
function returns an Int? Does specifying the route like that as a typed param mean that I don't have to typecheck within the function? I'm passing this to a SQL query so I want to double check that it's an Int so I don't get injected. I'm unclear about what happens behind the scenes when I declare the :users_id::Int
param within the route.
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
If you pass a parameter of the wrong type, the route handler will not run and it will throw a 404 error. Also, in the terminal you'll see something like this:
Error: 2023-11-20 09:43:28 ArgumentError("invalid base 10 digit 'a' in "addasd"")
![Author Avatar](https://cdn.discordapp.com/avatars/217063427242328066/7925f152a0bf7c71e85bbbd09df4fbfa.png?size=512)
cool, thank you!
![Author Avatar](https://cdn.discordapp.com/avatars/738049963250155580/13375362e7047976b44a466ef441a20f.png?size=512)
if it can't be converted to the indicated type, the route won't match