Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jericopulvera's avatar

$this->validate vs Validator::make?

what's the difference between these two?

$this->validate vs Validator::make?

0 likes
3 replies
michaeldyrynda's avatar
Level 41

The validate method will trap the failure and redirect back with errors and input automagically.

Validate::make builds a new Validator instance for you to work with.

With the latter, it's up to you to check fails or passes and handle each case as you see fit.

3 likes
wiedem's avatar

$this->validate uses the ValidatesRequests trait, creates a validator, automatically validates the request and throws an exception for you upon validation errors.
I.e. it does 3 things for you: validator creation, validate the data, throw an exception on errors.

Validator::make uses the Validator facade to create a validator instance for you. Nothing more. You have to execute the validation and implement the error handling yourself.
If you need more than $this->validate does then simply creating a validator instance via the facade (or via the validator factory ...) is the right way to do it.

Edit: @deringer was a little faster ;-) I'll leave my answer up anyways ...

3 likes
hackcharms's avatar

Practical uses difference between both are, $this->validate () return validation error handling message in session data that uses in same session and Validator::make provides all controll to handle errors and error message manually. So if we are working on ajax request then using Validator::make is only option.

Please or to participate in this conversation.