2014-06-21 01:36:44 +04:00
|
|
|
var PostValidator = Ember.Object.create({
|
2014-06-30 07:43:25 +04:00
|
|
|
check: function (model) {
|
2014-06-21 01:36:44 +04:00
|
|
|
var validationErrors = [],
|
2014-09-21 22:56:30 +04:00
|
|
|
data = model.getProperties('title', 'meta_title', 'meta_description');
|
2014-06-21 01:36:44 +04:00
|
|
|
|
2014-09-21 22:56:30 +04:00
|
|
|
if (validator.empty(data.title)) {
|
2014-06-21 01:36:44 +04:00
|
|
|
validationErrors.push({
|
|
|
|
message: 'You must specify a title for the post.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-09-21 22:56:30 +04:00
|
|
|
if (!validator.isLength(data.meta_title, 0, 70)) {
|
|
|
|
validationErrors.push({
|
|
|
|
message: 'Meta Title is too long.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validator.isLength(data.meta_description, 0, 156)) {
|
|
|
|
validationErrors.push({
|
|
|
|
message: 'Meta Description is too long.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-21 01:36:44 +04:00
|
|
|
return validationErrors;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default PostValidator;
|