mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 09:52:09 +03:00
9eac05e082
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
38 lines
1.1 KiB
JavaScript
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();
|
|
}
|
|
}
|
|
});
|