2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
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-23 19:46:03 +04:00
|
|
|
if (!validator.isLength(data.meta_title, 0, 150)) {
|
2014-09-21 22:56:30 +04:00
|
|
|
validationErrors.push({
|
2014-09-23 19:46:03 +04:00
|
|
|
message: 'Meta Title cannot be longer than 150 characters.'
|
2014-09-21 22:56:30 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-09-23 19:46:03 +04:00
|
|
|
if (!validator.isLength(data.meta_description, 0, 200)) {
|
2014-09-21 22:56:30 +04:00
|
|
|
validationErrors.push({
|
2014-09-23 19:46:03 +04:00
|
|
|
message: 'Meta Description cannot be longer than 200 characters.'
|
2014-09-21 22:56:30 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-21 01:36:44 +04:00
|
|
|
return validationErrors;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default PostValidator;
|