Ghost/core/client/app/validators/post.js
Kevin P. Kucharczyk 9eac05e082 Standardise client property names to camelCase
closes #6018
- added keyForAttribute method in application serializer
- override keyForAttribute in settings serializer to not apply camelCase/underscore conversion
- rename under_scored properties to camelCased
2016-01-23 19:12:22 +01: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('metaTitle');
if (!validator.isLength(metaTitle, 0, 150)) {
model.get('errors').add('metaTitle', 'Meta Title cannot be longer than 150 characters.');
this.invalidate();
}
},
metaDescription(model) {
let metaDescription = model.get('metaDescription');
if (!validator.isLength(metaDescription, 0, 200)) {
model.get('errors').add('metaDescription', 'Meta Description cannot be longer than 200 characters.');
this.invalidate();
}
}
});