-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Description
What needs to be done?
In the request classes GetRequest and SearchRequest , add validation for the specified relations using the rule pattern: $availableRelations = implode(',', $this->getAvailableRelations()); 'with.*' => 'required|string|in:' . $availableRelations
Implement the protected method getAvailableRelations() that returns an array of allowed relations provided.
Add the comment before this method: // TODO: don't forget to review relations list
Expected Outcome
What is the expected result?
The requests will validate the with relations parameter correctly, only allowing those specified in getAvailableRelations() . This prevents invalid relations from passing validation and ensures consistent relation handling.
Verification Scenarios
How can this be tested?
Test requests with valid relations such as
roleincluded inwithand confirm they pass validation.Test requests with invalid or missing relations in
withand confirm validation errors are returned.Confirm the
getAvailableRelations()method is present and preceded by the specifiedTODOcomment.Ensure no errors or warnings occur related to relations validation.
Resources
Materials
Example of using the with field check: https://github.com/RonasIT/laravel-empty-project/blob/development/app/Http/Requests/Users/SearchUserRequest.php