vendredi 4 décembre 2015

laravel 5.1 validation rule alpha cannot take whitespace, what should i do?

i have created a a registration form where a farmer will input his name. name may contain hyphen or white spaces. the validation rules are written in app/http/requests/farmerRequest.php file .

public function rules()
    {
        return [
            'name'          => 'required|alpha',
            'email'         => 'email|unique:users,email',
            'password'      => 'required',
            'phone'         => 'required|numeric',
            'address'       => 'required|min:5',
    ];
    }

but the problem is the name field is not allowing any whitespaces because of the rule alpha.(name field is varchar(255)collation utf8_unicode_ci)

what should i do to so that user can input his name with whitespaces?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire