Validation in Laravel
avoid space in username.
'username' => ['required', 'string', 'max:255', 'unique:users', 'regex:/^\S*$/u'],
alpha_dash is a default Laravel validation rule which allows letters, numbers, dashes and underscores and NOT space.
'username' => ['required', 'string', 'max:255', 'unique:users', 'alpha_dash'],
Laravel 5.7,5.8:
return Validator::make($data, [ 'A' => ['required', 'string'], 'B' => ['required', 'string', 'max:255'], ]);
Older versions:
return Validator::make($data, [ 'A' => 'required|string', 'B' => 'required|string|max:255', ]); $rule=array( 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|max:75|unique:users', 'mobile' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10', 'password' => 'required|min:3|confirmed' );
40 Additional Laravel Validation Rules
https://laraveldaily.com/40-additional-laravel-validation-rules/
https://laraveldaily.com/how-to-create-custom-validation-rules-laravel/
Comments
Post a Comment