2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Validation fix for number of posts/page

closes #3641
- Reworded error messages, remove “please” (credits go to @YouriAckx)
This commit is contained in:
Felix Rieseberg 2014-08-07 19:58:25 -07:00
parent 8e17efeac9
commit f19c2be6fe
4 changed files with 14 additions and 10 deletions

View file

@ -58,7 +58,7 @@
<div class="form-group">
<label for="postsPerPage">Posts per page</label>
{{input id="postsPerPage" name="general[postsPerPage]" type="number" value=postsPerPage}}
{{input id="postsPerPage" name="general[postsPerPage]" value=postsPerPage min="1" max="1000" type="number"}}
<p>How many posts should be displayed on each page</p>
</div>

View file

@ -15,15 +15,19 @@ var SettingValidator = Ember.Object.create({
}
if (!validator.isEmail(email) || !validator.isLength(email, 0, 254)) {
validationErrors.push({ message: 'Please supply a valid email address' });
validationErrors.push({ message: 'Supply a valid email address' });
}
if (!validator.isInt(postsPerPage) || postsPerPage > 1000) {
validationErrors.push({ message: 'Please use a number less than 1000' });
if (postsPerPage > 1000) {
validationErrors.push({ message: 'The maximum number of posts per page is 1000' });
}
if (!validator.isInt(postsPerPage) || postsPerPage < 0) {
validationErrors.push({ message: 'Please use a number greater than 0' });
if (postsPerPage < 1) {
validationErrors.push({ message: 'The minimum number of posts per page is 1' });
}
if (!validator.isInt(postsPerPage)) {
validationErrors.push({ message: 'Posts per page must be a number' });
}
return validationErrors;

View file

@ -44,7 +44,7 @@
"validations": {
"isNull": false,
"isInt": true,
"isLength": [0, 1000]
"isLength": [1, 1000]
}
},
"forceI18n": {

View file

@ -143,7 +143,7 @@ CasperTest.begin('General settings validation is correct', 7, function suite(tes
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number');
test.assertSelectorHasText('.notification-error', 'must be a number');
}, casper.failOnTimeout(test, 'postsPerPage error did not appear'), 2000);
casper.thenClick('.js-bb-notification .close');
@ -154,7 +154,7 @@ CasperTest.begin('General settings validation is correct', 7, function suite(tes
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number less than 1000');
test.assertSelectorHasText('.notification-error', 'maximum number of posts per page is 1000');
}, casper.failOnTimeout(test, 'postsPerPage max error did not appear', 2000));
casper.thenClick('.js-bb-notification .close');
@ -165,7 +165,7 @@ CasperTest.begin('General settings validation is correct', 7, function suite(tes
});
casper.waitForSelectorTextChange('.notification-error', function onSuccess() {
test.assertSelectorHasText('.notification-error', 'use a number greater than 0');
test.assertSelectorHasText('.notification-error', 'minimum number of posts per page is 1');
}, casper.failOnTimeout(test, 'postsPerPage min error did not appear', 2000));
});