mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
78affdedb1
closes #3153 - this is all about the validation engine - add a option, `opts.model`, to use a passed-in model directly if needed - handle validators that return an array of strings, array of objects, or both - ajax util returns either an array of errors or a single concat'd string - remove formatErrors function from the mixin and make it private - allow validation options to be passed into `.save()` since ember-data doesn't take params on `.save()` anyway - streamline control flow
25 lines
659 B
JavaScript
25 lines
659 B
JavaScript
var ResetValidator = Ember.Object.create({
|
|
check: function (model) {
|
|
|
|
var data = model.getProperties('passwords'),
|
|
p1 = data.passwords.newPassword,
|
|
p2 = data.passwords.ne2Password,
|
|
validationErrors = [];
|
|
|
|
if (!validator.equals(p1, p2)) {
|
|
validationErrors.push({
|
|
message: 'The two new passwords don\'t match.'
|
|
});
|
|
}
|
|
|
|
if (!validator.isLength(p1, 8)) {
|
|
validationErrors.push({
|
|
message: 'The password is not long enough.'
|
|
});
|
|
}
|
|
return validationErrors;
|
|
}
|
|
});
|
|
|
|
export default ResetValidator;
|