what is validator in laravel code example
Example 1: validate laravel
$validatedData = $request->validate([
'title' => ['required', 'unique:posts', 'max:255'],
'body' => ['required'],
]);
Example 2: what is validator in laravel
$validator = Validator::make(
[
'name' => 'Dayle',
'password' => 'lamepassword',
'email' => '[email protected]'
],
[
'name' => 'required',
'password' => 'required|min:8',
'email' => 'required|email|unique:users'
]
);
if ($validator->fails())
{
// The given data did not pass validation
}