Add new rules in laravel validations in Laravel 8
//Rule
use Illuminate\Validation\Rule;
$validator = Validator::make($request->all(), [
'email' => 'required|unique:users|max:255|email:rfc,dns',
'username' => [
'required','min:4',
Rule::unique('users')->where(function ($query) {
$query->where('is_verified','=', '1');
return $query;
})
],
'displayname' => 'required',
'password' => 'required',
],$messages = [], [
'email' => 'Email',
'username' => 'Username',
'displayname' => 'Display Name',
'password' => 'Password',
]);
Comments
Post a Comment