Do you know the form request validation ?
https://laravel.com/docs/10.x/validation#form-request-validation
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am Learning laravel. I am creating a site where I need user register. I created a Request Validation file for registering. now I need to fully validate email, password and confirm password (like password must have 1 capital letter, 1 small letter, number, special character and length). how can I do that with laravel ???
@gemini_man93 When you need to store or update a model, you can add validation rules.
In the controller you have methods called for storing or updating a model.
public function store(Request $request)
{
...
}
Instead of using a simple request, you can use a form request.
public function store(CategoryRequest $request)
{
...
}
In this case, the store function will be executed only if the form request is validated according the rules you have defined.
public function rules()
{
return [
'name' => 'required|string',
'short_name' => 'required|string|max:5',
];
}
In this example, to store a new category, you need to save the name as a string and the short name as a string with a maximum length of 5, and both fields are required.
If only one of these rules is missing, the validation fails and returns automatically an error to tell you which validation rule fails.
And if you need more customizable rules, you can write more complex rules like in this example.
https://laravel.com/docs/10.x/validation#rule-required-if
You can write your own set of rules for the password. But you already have some specific rules for the passwords.
https://laravel.com/docs/10.x/validation#validating-passwords
Please or to participate in this conversation.