Create Custom Validation Rules In Laravel
This post is over a year old, so some information in the post may be out-dated or not relevant any more.
One thing I really love about Laravel is its built-in
Any time I need some kind of custom validation rule on an attribute, I make a custom validation rule because I can then reuse the rule on any other attribute that might need the same kind of validation.
Let's say you have a form where a user can update their password on some kind of profile page, but you don't want them to enter a password that contains their name. This could easily be accomplished with a custom validation rule.
The custom rule would look like this:
You could then use the validation rule in a request like this:
That's really all there is to creating a custom validation rule and using it. The rule shown above is an extremely simple example of what is possible with a custom validation rule.
For a more in-depth explanation on this take a look at a