1

I'm using ardent to validate my User model but for some reason it's always returning the two following errors:

  • The password confirmation does not match.
  • The password confirmation field is required.

I've been stumped on the one for a while so any help is appreciated. Guessing it has do to with my setup or Ardent but can't figure it out. My unit tests are passing the follow test route also passes:

Route::get('testuser', function() {
    $user                        = new User;
    $user->first_name            = 'John';
    $user->last_name             = 'Doe';
    $user->birthday              = '11/11/11/';
    $user->email                 = 'johndoe@gmail.com';
    $user->password              = 'password';
    $user->password_confirmation = 'password';

    var_dump($user->save());
});

I'm not creating the user this way on form submit though. My controller action looks like this:

$user = $this->user->create(Input::all());

if ($user->save()) {
     return Redirect::route('users.index')
          ->with('flash', 'The new user has been created');
}

return Redirect::route('register.index')
     ->withInput()
     ->withErrors($user->errors());

With the Input::all() array equalling:

array (
  '_token' => 'removed',
  'first_name' => 'John',
  'last_name' => 'Doe',
  'birthday' => '11/11/11',
  'email' => 'johndoe@gmail.com',
  'password' => 'password',
  'password_confirmation' => 'password',
)

And finally my User model is set up like so:

class User extends Ardent implements UserInterface, RemindableInterface {

    protected $table                     = 'users';

    protected $hidden                    = array();

    protected $fillable                  = array(
        'email',
        'first_name',
        'last_name',
        'birthday',
        'password',
        'password_confirmation'
    );

    protected $guarded                   = array('id');

    public static $passwordAttributes    = array('password');

    public $autoPurgeRedundantAttributes = true;

    public $autoHydrateEntityFromInput   = false;

    public static $rules = array(
        'email'                 => 'required|email|unique:users',
        'first_name'            => 'required',
        'last_name'             => 'required',
        'birthday'              => 'required',
        'password'              => 'required|alpha_num|min:6|confirmed',
        'password_confirmation' => 'required|alpha_num|min:8',
    );
Shane Da Silva
  • 469
  • 1
  • 6
  • 15
  • 1
    Why do you have different `min` settings for each password? For password confirmation you can omit all validation methods and replace with `same:password` which will inherit as it needs to match. – ollieread Mar 13 '14 at 09:09

0 Answers0