New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] Retrieve only validated inputs from FormRequest #18665

wants to merge 2 commits into
base: 5.4


None yet
3 participants

timacdonald commented Apr 5, 2017

This allows you to call $this->validatedInputs() on Form Request objects and only retrieve inputs that have rules associated with them, i.e. only validated rules.

Helps keep in check that you are validating all the input that goes into your models as well I find.

This is something I do in my form objects just to make things that little nicer. Thought it might be helpful to others....maybe?


in a PostRequestForm class set your rules as per normal:

public function rules()
    return [
        'title' => 'required|string|max:30',
        'content' => 'required|string'

Then in your controller you can just call:

public function store(PostRequestForm $form)

For pretty simple rules, this is great, but might not work so well for more complex rules such and open to suggestions for making it work well with these kind of rules.

'users.*.email' => 'required|email'

@timacdonald timacdonald changed the title from 5.4 Retrieve only validated inputs from FormRequest to [5.4] Retrieve only validated inputs from FormRequest Apr 5, 2017


This comment has been minimized.


antonkomarev commented Apr 5, 2017

Interesting idea


This comment has been minimized.


taylorotwell commented Apr 5, 2017

Hmm, it's a neat idea. Might let you just define it on your own form requests but I'll keep it in mind for the future. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment