Ghost/ghost/admin/app/validators/post.js
Kevin Ansfield 2f4f6db133 Use es6 across client and add ember-suave to enforce rules
no issue
- add ember-suave dependency
- upgrade grunt-jscs dependency
- add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc
- separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc
- standardize es6 usage across client
2015-11-30 10:41:01 +00:00

38 lines
1.1 KiB
JavaScript

import BaseValidator from './base';
export default BaseValidator.create({
properties: ['title', 'metaTitle', 'metaDescription'],
title(model) {
let 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(model) {
let 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(model) {
let 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();
}
}
});