validation.alpha_spaces is the output of a missing translation. The second piece of code in the tutorial you linked adds the custom validation error.
Add the following to your lang/en/validation.php file:
/*
|--------------------------------------------------------------------------
| Custom Validation Rules
|--------------------------------------------------------------------------
|
| Custom rules created in app/validators.php
|
*/
"alpha_spaces" => "The :attribute may only contain letters and spaces.",
As for allowing numbers, add \d to the regular expression. So their first snippet would look like:
/*
* app/validators.php
*/
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s\d]+$/u', $value);
});
Bare in mind that \d will allow all digit characters, such as ٠١٢٣٤٥٦٧٨٩. Use 0-9 instead if you don't want that.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.