3

I'm quite new to both RESTful API's and Laravel 5, so excuse me for any dumb questions. :-)

What's the best way to validate API requests (POST/PUT) in Laravel 5? I've learned about Form Request Validation, but that seems targeted towards forms. Would it make any sense to use this for a HTTP REST API as well? Is there a better alternative?

Also, how would one go about validating query strings in GET requests? Is that something to handle in the controller itself?

1 Answer 1

6

The best option is to use the Form Request Validation. The word "form" in the title is misleading - as it is really the ability to handle validation on any request - regardless of the source.

You can handle GET requests inside the Request validator - so that all your validation is in one single location.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.