mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
6020702462
closes #2893, issue #2850, issue #2856 - this is a stable, but quick and dirty validations layer for the time constraints - this could be replaced with a unified server/client layer later. the infrastructure is there. - create a validation engine mixin to match validators with models - override the save method in the mixin to perform validations first - create a post validator - fixup calls to .save() to make sure they catch errors properly
18 lines
393 B
JavaScript
18 lines
393 B
JavaScript
var PostValidator = Ember.Object.create({
|
|
validate: function (model) {
|
|
var validationErrors = [],
|
|
|
|
title = model.get('title');
|
|
|
|
if (validator.empty(title)) {
|
|
validationErrors.push({
|
|
message: 'You must specify a title for the post.'
|
|
});
|
|
}
|
|
|
|
return validationErrors;
|
|
}
|
|
});
|
|
|
|
export default PostValidator;
|