Following: https://laravel.com/docs/5.7/validation#using-closures
I have added below code in myServiceProvider
public function boot()
{
\Validator::extend('foo', function ($attribute, $value, $parameters, $validator) {
if('fname' === $value)
return true;
return false;
});
}
Now, for custom error message what does this line mean? using an inline custom message array
what should be the syntax?
Defining The Error Message
You will also need to define an error message for your custom rule. You can do so either using an inline custom message array or by adding an entry in the validation language file. This message should be placed in the first level of the array, not within the custom array, which is only for attribute-specific error messages: