Complete the code to create a custom validation rule class in Laravel.
php artisan make:[1] UniqueEmailThe correct artisan command to create a custom validation rule is make:rule.
Complete the method signature to define the validation logic inside the custom rule class.
public function [1]($attribute, $value) { }The method passes is used in Laravel custom rules to define validation logic.
Fix the error in the validation logic to fail validation when the value is not 'admin'.
if ($value !== '[1]') { $fail('The :attribute must be admin.'); }
The validation should fail if the value is not 'admin', so the string 'admin' must be used.
Fill both blanks to register the custom rule in a form request's rules method.
public function rules() {
return [
'email' => ['required', new [1]()],
'username' => ['required', '[2]'],
];
}The custom rule class is UniqueEmail, and 'string' is a standard Laravel validation rule.
Fill all three blanks to create a custom validation rule that checks if a number is even.
public function passes($attribute, $value) {
return $value [1] 2 [2] 0;
}
public function message() {
return '[3]';
}The modulo operator '%' checks remainder, '==' compares equality, and the message explains the validation rule.