mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
5c9a824d53
no issue - drops the `var Foo = Ember.Thing.extend({}); export default Foo;` syntax in favour of exporting directly, eg: `export default Ember.Thing.extend({})` - discussion on this change [here](https://github.com/TryGhost/Ghost/pull/5340#issuecomment-105828423) and [here](https://github.com/TryGhost/Ghost/pull/5694#discussion-diff-37511606)
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import BaseValidator from './base';
|
|
|
|
export default BaseValidator.create({
|
|
properties: ['title', 'metaTitle', 'metaDescription'],
|
|
|
|
title: function (model) {
|
|
var title = model.get('title');
|
|
|
|
if (validator.empty(title)) {
|
|
model.get('errors').add('title', 'You must specify a title for the post.');
|
|
this.invalidate();
|
|
}
|
|
|
|
if (!validator.isLength(title, 0, 150)) {
|
|
model.get('errors').add('title', 'Title cannot be longer than 150 characters.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
metaTitle: function (model) {
|
|
var metaTitle = model.get('meta_title');
|
|
|
|
if (!validator.isLength(metaTitle, 0, 150)) {
|
|
model.get('errors').add('meta_title', 'Meta Title cannot be longer than 150 characters.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
metaDescription: function (model) {
|
|
var metaDescription = model.get('meta_description');
|
|
|
|
if (!validator.isLength(metaDescription, 0, 200)) {
|
|
model.get('errors').add('meta_description', 'Meta Description cannot be longer than 200 characters.');
|
|
this.invalidate();
|
|
}
|
|
}
|
|
});
|