garygreen / dominar

Lightweight bootstrap validator inspired by Laravel
http://garygreen.github.io/dominar/
22 stars 4 forks source link

confirmed syntax help #16

Closed stocksp closed 9 years ago

stocksp commented 9 years ago

I thought that this would work

password: {
      rules: 'required|min:4'
 },
 passwordConfirm: {
      rules: 'required|confirmed:password'
 }

The above never validates ... always generates a required error or 'The passwordConfirm confirmation does not match.' The confirmed method in Validator (line450) always fails as it seem to be looking for a property with the name of my control (in this case 'passwordConfirm' ) plus a '_confirmation' appended to it. Which doesn't exist. Nothing in the this context even has the value of the password control .... so I'm confused about how to use the 'confirmed' built in validator.

garygreen commented 9 years ago

I totally didn't think of this, there's a bit of a logic fail in dominar to get this to work. Ideally this should work (will need supporting in validatorjs):

password: {
    rules: 'required|confirmed'
},
password_confirmation: {
    rules: 'required|confirmed:password'
}

Will look into it.

garygreen commented 9 years ago

Fixed in 1b616610f576b5bd27302cca97b83fa3ed66ae9e