Monday 20 March 2017

Username validation using Regis on Laravel

Please find the validation script below to fix the username validation allowing it to have only Alphanumeric with dot (.), dash/hypen (-) and underscore(_).

$validator = Validator::make($request->all(),
            ['user_name' =>
                ['required', 'min:4', 'max:20', 'unique:auth_users', 'Regex:/^[a-zA-Z0-9-._]+$/']
            ]


No comments:

Post a Comment

Please post any queries and comments here.