mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-17 21:41:49 +03:00
b9f9c576ed
Closes #3036 Refs #3012 -Enable validation for settings/general -Turn on functional tests for the validations -Move notification closeAll calls so that notifications are cleared on attempted saves instead of just on successful saves
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
var SettingValidator = Ember.Object.create({
|
|
validate: function (model) {
|
|
var validationErrors = [],
|
|
title = model.get('title'),
|
|
description = model.get('description'),
|
|
email = model.get('email'),
|
|
postsPerPage = model.get('postsPerPage');
|
|
|
|
if (!validator.isLength(title, 0, 150)) {
|
|
validationErrors.push({ message: 'Title is too long' });
|
|
}
|
|
|
|
if (!validator.isLength(description, 0, 200)) {
|
|
validationErrors.push({ message: 'Description is too long' });
|
|
}
|
|
|
|
if (!validator.isEmail(email) || !validator.isLength(email, 0, 254)) {
|
|
validationErrors.push({ message: 'Please supply a valid email address' });
|
|
}
|
|
|
|
if (!validator.isInt(postsPerPage) || postsPerPage > 1000) {
|
|
validationErrors.push({ message: 'Please use a number less than 1000' });
|
|
}
|
|
|
|
if (!validator.isInt(postsPerPage) || postsPerPage < 0) {
|
|
validationErrors.push({ message: 'Please use a number greater than 0' });
|
|
}
|
|
|
|
return validationErrors;
|
|
}
|
|
});
|
|
|
|
export default SettingValidator;
|