When we’re building web apps, one of our most common workflows is code that collects and validates user input. However, some times we want to validate data that’s a part of the request but wasn’t provided by the user—for example, a part of the URL. In this post, we’ll explore four possible validation solutions for validating data on a request that wasn’t provided by the user.
Each form request has a rules() method, which allows us to define how to validate each piece of user input. Since the examples we’re covering here aren’t validating user input, we might assume the rules() method, which traditionally pulls only the user data (using request()->all()), would be out of the question.