Skip to main content
Sometimes a more fine-grained control over the validation is required. In such case you can hook into the validator.

Overwriting messages

It is possible to overwrite the error messages that will be returned when a validation rule fails:

Overwriting attributes

In the default Laravel validation rules, you can overwrite the name of the attribute as such:

Overwriting other validation functionality

Next to overwriting the validator, attributes and messages it is also possible to overwrite the following functionality.

Redirect when validation fails

The redirect when a validation failed:
Or the route which will be used to redirect after a validation failed:

Stop on first failure

Whether to stop validating on the first failure:

Error bag name

The name of the error bag:

Using dependencies in overwritten functionality

You can also provide dependencies to be injected in the overwritten validator functionality methods like messages, attributes, redirect, redirectRoute, stopOnFirstFailure, errorBag:

Overwriting the validator

Before validating the values, it is possible to plugin into the validator. This can be done as such:
This method will only be called on the root data object that is being validated, all the nested data objects and collections withValidator methods will not be called.