I have a general structure for a Symfony controller (using FOSRestBundle)
public function getUserAction(User $user)
{
}
Now, if I ask http://localhost/users/1, everything will be all right. But if I ask http://localhost/users/11111111111111111, I get 500 errors and an exception
ERROR: value \"11111111111111111\" is out of range for type integer"
Is there a way to verify the identifier before passing it to the database?
As a solution, I can specify the length of id
/**
* @Route\Get("users/{id}", requirements={"userId" = "(\d{,10})"})
*/
but then Symfony will say that there is no such route, instead of showing that the identifier is incorrect.
source
share