+2 votes
in Laravel by
How to do request validation in Laravel?

1 Answer

0 votes
by

Request validation in laravel can be done with the controller method or we can create a request validation class that holds the rules of validation and the error messages associated with it.

One example of it can be seen below:

/**

 * Store a new blog post.

 *

 * @param  \Illuminate\Http\Request  $request

 * @return \Illuminate\Http\Response

 */

public function store(Request $request)

{

    $validated = $request->validate([

        'title' => 'required|unique:posts|max:255',

        'body' => 'required',

    ]);

    // The blog post is valid...

}

Related questions

0 votes
asked Oct 25, 2023 in Laravel by rajeshsharma
+1 vote
asked Jul 12, 2021 in Laravel by sharadyadav1986
...