Support the ongoing development of Laravel.io →
Configuration Input Validation

Hi

In Laravel 4 this code works like a charm. But in Laravel 4.1 this don't work.

start/global.php

require app_path().'/validators.php';

validators.php

<?php

// Crear validación de alpha espacios
Validator::extend('alpha_spaces', function($attribute, $value, $parameters)
{
    return preg_match('/^[\pL\s]+$/u', $value);
});
      

UsersController

.....
        $reglas = array(
            'first_name'    => 'required|alpha_spaces|min:3|max:30',
            'last_name'     => 'required|alpha_spaces|min:3|max:30',
            'email'         => 'required|email|unique:users,email',
            'password'      => 'required|confirmed'
        );

And the lenguage file (same for alpha)

I put in the form (first_name and/or last_name) any simple word (for example: laravel) and the validation fails: "The first name may only contain letters and numbers". The question is. WHY?

Thanks


Offtopic: I don't like this new forum format. Force to login with github? Tags?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.