I'm currently building an API route in Laravel 7. I want to validate that a given parameter only appears once in the request.
https://mycool.api/?cool=false&user=me&cool=true
For a URI like the above, my desire is that Laravel would error with a message like "You sent 2 values for parameter cool
". The current behavior seems to be to simply use the 2nd appearance of the parameter and in my example case set the value of cool
= true.
I currently have validators like:
$rules = [
'user' => 'required|in:me,you',
'param' => 'accepted'
];
Is there a validator that can achieve this? Or some other Laravel built-in solution?