2015-06-06 22:19:19 -05:00
|
|
|
import BaseValidator from './base';
|
|
|
|
var ResetValidator = BaseValidator.create({
|
|
|
|
properties: ['newPassword'],
|
|
|
|
newPassword: function (model) {
|
2014-10-02 09:12:54 -06:00
|
|
|
var p1 = model.get('newPassword'),
|
2015-06-06 22:19:19 -05:00
|
|
|
p2 = model.get('ne2Password');
|
2014-06-27 20:08:16 +01:00
|
|
|
|
2015-07-07 18:14:23 +01:00
|
|
|
if (validator.empty(p1)) {
|
|
|
|
model.get('errors').add('newPassword', 'Please enter a password.');
|
|
|
|
this.invalidate();
|
|
|
|
} else if (!validator.isLength(p1, 8)) {
|
2015-06-06 22:19:19 -05:00
|
|
|
model.get('errors').add('newPassword', 'The password is not long enough.');
|
|
|
|
this.invalidate();
|
2015-07-11 13:04:19 -04:00
|
|
|
} else if (!validator.equals(p1, p2)) {
|
|
|
|
model.get('errors').add('ne2Password', 'The two new passwords don\'t match.');
|
|
|
|
this.invalidate();
|
2014-06-27 20:08:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default ResetValidator;
|