-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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.5] Add a validate method onto the request #19063
Conversation
d4a9d6f
to
0354fb2
Compare
A request shouldn't know how to validate itself!!!11!!one!!!!!111!!eleven!!111!!elf!! |
I don't understand the point of this |
I'm very much in favour of this. I've been doing this with macros for quite some time: public function registerValidate()
{
Request::macro('validate', function ($rules, $messages = [], $customAttributes = []) {
(new class() {
use ValidatesRequests;
})->validate($this, $rules, $messages, $customAttributes);
});
} Which, as you can see, it takes a little magic when done as a macro, so having this built in gets a big 👍 fro me. |
Hmm, I guess I could have use the |
Why didn't this go to the request object? :) |
@gocanto Laravel's components are decoupled from each other as much as possible. You should be able to pull in only some of its components into a non-Laravel project, and have it work without pulling in all of the framework. Since the In addition to all of the standalone components, Laravel has a separate |
@JosephSilber Excelente. Thanks for the explanation! |
This will allow calling
validate
directly on the request object: