I have read in the documentation how to create new custom validation rule.
I have made one like the one in the example but to only allow lowercase. The class is creatively named Lowercase.
Now I want to add that to the Validator-list in the RegisterController generated from make:auth. This is the list I want to add it to:
return Validator::make($data, [
'name' => 'required|string|max:255|**ADD MY VALIDATOR HERE**',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
Obviously there is something here I am missing... In the documentation it says to use the one I have done like this:
$request->validate([
'name' => ['required', 'string', new Lowercase],
]);
What do I need to do to be able to add my custom rule to the list above?
EDIT 1:
Per request I am showing the rule I have created. It is IDENTICALL to the one in the linked example in the documentation but I have switched the name of it from Uppercase to Lowercase and strtoupper to strtolower
public function passes($attribute, $value)
{
return strtolower($value) === $value;
}