0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Merge pull request #5548 from acburdine/inline-errors-fix

Fix some validation bugs
This commit is contained in:
Hannah Wolfe 2015-07-12 10:44:27 +01:00
commit d57c0d43e2
3 changed files with 16 additions and 24 deletions

View file

@ -125,17 +125,15 @@ export default Ember.Mixin.create({
return reject(['The validator specified, "' + type + '", did not exist!']);
}
if (opts.property) {
model.get('errors').remove(opts.property);
} else {
model.get('errors').clear();
}
passed = validator.check(model, opts.property);
if (passed) {
if (opts.property) {
model.get('errors').remove(opts.property);
} else {
model.get('errors').clear();
}
return resolve();
}
return reject();
return (passed) ? resolve() : reject();
});
},

View file

@ -5,14 +5,12 @@ var ResetValidator = BaseValidator.create({
var p1 = model.get('newPassword'),
p2 = model.get('ne2Password');
if (!validator.equals(p1, p2)) {
model.get('errors').add('ne2Password', 'The two new passwords don\'t match.');
this.invalidate();
}
if (!validator.isLength(p1, 8)) {
model.get('errors').add('newPassword', 'The password is not long enough.');
this.invalidate();
} else if (!validator.equals(p1, p2)) {
model.get('errors').add('ne2Password', 'The two new passwords don\'t match.');
this.invalidate();
}
}
});

View file

@ -30,19 +30,15 @@ var SettingValidator = BaseValidator.create({
postsPerPage: function (model) {
var postsPerPage = model.get('postsPerPage');
if (postsPerPage > 1000) {
model.get('errors').add('postsPerPage', 'The maximum number of posts per page is 1000');
this.invalidate();
}
if (postsPerPage < 1) {
model.get('errors').add('postsPerPage', 'The minimum number of posts per page is 1');
this.invalidate();
}
if (!validator.isInt(postsPerPage)) {
model.get('errors').add('postsPerPage', 'Posts per page must be a number');
this.invalidate();
} else if (postsPerPage > 1000) {
model.get('errors').add('postsPerPage', 'The maximum number of posts per page is 1000');
this.invalidate();
} else if (postsPerPage < 1) {
model.get('errors').add('postsPerPage', 'The minimum number of posts per page is 1');
this.invalidate();
}
}
});