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

Hello there,

i am trying a really simple form validation, but somehow it does not work out.

here is my registration form:

<h1>Registration form</h1>

{{ Form::open(array('url' => 'registration')) }}

{{-- Username field. ------------------------}}
{{ Form::label('username', 'Username') }}
{{ Form::text('username') }}

{{-- Email address field. -------------------}}
{{ Form::label('email', 'Email address') }}
{{ Form::email('email') }}

{{-- Password field. ------------------------}}
{{ Form::label('password', 'Password') }}
{{ Form::password('password') }}

{{-- Password confirmation field. -----------}}
{{ Form::label('password_confirmation', 'Password confirmation') }}
{{ Form::password('password_confirmation') }}

{{-- Form submit button. --------------------}}
{{ Form::submit('Register') }}

{{ Form::close() }}

And thats my Route::post :

Route::post('/registration',function()
{
    // Fetch all request data.
    $data = Input::all();
    
    $rules = array(
        'username' => 'required|alpha_num|min:3|max:32',
        'email' => 'required|email',
        'password' => 'required|min:3|confirm',
        'password_confirmation' => 'required|min:3'
    );

    // Create a new validator instance.
    $validator = Validator::make($data, $rules);
    

    if ($validator->passes()) {
        
        //Something
        return 'Data was saved';
    }
    
    return Redirect::to('/')->withErrors($validator);
     
});

It seems like the 'confirm' is the problem, whenever i dont comment it out i get:

Whoops, looks like something went wrong.

tried everything so far, would be really glad if someone could help me out here.

i am little bit of a noob in laravel to be honest ;)

thanks.

Last updated 3 years ago.
0

confirmed*

Last updated 3 years ago.
0

You have a small typo in your rules. It should be:

$rules = array(
        'username' => 'required|alpha_num|min:3|max:32',
        'email' => 'required|email',
        'password' => 'required|min:3|confirmed',
        'password_confirmation' => 'required|min:3'
    );

Just for your knowledge, you don't really need to validate password_confirmation. If it must match password, then it must also have the same validation. :)

Last updated 3 years ago.
0

FYI, if your application is still in development, change 'debug' => false, to 'debug' => true, in your app/config.php so you can see the detailed information of the error and faster identity where is the error.

Last updated 3 years ago.
0

I have a similar problem with Password not working with confirmed. If I take |confirmed out of the password parameter it saves the user but allows a password of less than 6 characters. Can you let me know the correct syntax to have min:6 and confirmed working?

public static $rules = [
	'username' => 'required',
	'email' => 'required|unique:users|email',		
	'password' => 'min:6|required',
	'password_confirmation' => 'min:6|same:pass'	
];
Last updated 3 years ago.
0

surferway said:

I have a similar problem with Password not working with confirmed. If I take |confirmed out of the password parameter it saves the user but allows a password of less than 6 characters. Can you let me know the correct syntax to have min:6 and confirmed working?

public static $rules = [ 'username' => 'required', 'email' => 'required|unique:users|email', 'password' => 'min:6|required', 'password_confirmation' => 'min:6|same:pass' ];

'password' => 'required|min:6|confirmed  
Last updated 3 years ago.
0

Solved password validation issue. Please try below method

public static $rules = [ 'username' => 'required', 'email' => 'required|unique:users|email',
'password' => 'min:6|required', 'password_confirmation' => 'min:6|same:password'
];

You can match two form field using (same:field name) this method.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

gilganebu gilganebu Joined 14 Jul 2014

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.