diff --git a/core/client/templates/settings/general.hbs b/core/client/templates/settings/general.hbs index c02dde975f..20a4c2ff5a 100644 --- a/core/client/templates/settings/general.hbs +++ b/core/client/templates/settings/general.hbs @@ -58,7 +58,7 @@
- {{input id="postsPerPage" name="general[postsPerPage]" type="number" value=postsPerPage}} + {{input id="postsPerPage" name="general[postsPerPage]" value=postsPerPage min="1" max="1000" type="number"}}

How many posts should be displayed on each page

diff --git a/core/client/validators/setting.js b/core/client/validators/setting.js index be47404dad..885d43faaa 100644 --- a/core/client/validators/setting.js +++ b/core/client/validators/setting.js @@ -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; diff --git a/core/server/data/default-settings.json b/core/server/data/default-settings.json index 0ec4de7827..c26da65687 100644 --- a/core/server/data/default-settings.json +++ b/core/server/data/default-settings.json @@ -44,7 +44,7 @@ "validations": { "isNull": false, "isInt": true, - "isLength": [0, 1000] + "isLength": [1, 1000] } }, "forceI18n": { diff --git a/core/test/functional/client/settings_test.js b/core/test/functional/client/settings_test.js index 1151efeaf1..491a7f7245 100644 --- a/core/test/functional/client/settings_test.js +++ b/core/test/functional/client/settings_test.js @@ -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)); });