Search code examples
javascriptember.jsember-app-kit

ember, ember-validations match password and confirmation


I've been successful in modifying the default classes and the negative class values to make sure that my ember-validations appear the way I want them to on load. Now, I'm diving into ember-validations. One of the validator routines I'm having little success with is the match: property. Here's the code from my controller:

    userLoginPass: {
        presence: { message: " password required" },
        match: { property: { "userRegPassConfirm" } }
    },
    userRegPassConfirm: {
        presence: { message: " confirm password required" },
        match: { property: { "userLoginPass" } }
    },

However, neither field barks on mis-match between them. Something is missing. Anyone had experience with this?

Here's the doc that's giving me problems: https://github.com/lcoq/ember-validations#match

Many Sincere Thanks!


Solution

  • Turns out the answer is a two part process which includes making sure the confirmation field is labelled whateverConfirmation in addition to the confirmation property like so:

    password: {
      confirmation: true,
         presence: {
           message: ' password required'
         }
       },
    
    passwordConfirmation: {
      presence: {
        message: ' please confirm password'
        }
      }
    

    as seen on the ember-validations documentation page:

    https://github.com/dockyard/ember-validations#confirmation