Ghost/ghost/admin/app/validators/setting.js
Kevin Ansfield 042aecb7f6 Switch from embor-browserify to ember-auto-import
no issue
- minor reduction in build size. Before/after:
  - `vendor.min.js 3.32 MB (710.66 KB gzipped)`
  - `vendor.min.js 3.29 MB (706 KB gzipped)`
2019-01-22 13:09:38 +00:00

34 lines
940 B
JavaScript

import BaseValidator from './base';
import validator from 'validator';
export default BaseValidator.create({
properties: ['title', 'description', 'password'],
title(model) {
let title = model.get('title');
if (!validator.isLength(title || '', 0, 150)) {
model.get('errors').add('title', 'Title is too long');
this.invalidate();
}
},
description(model) {
let desc = model.get('description');
if (!validator.isLength(desc || '', 0, 200)) {
model.get('errors').add('description', 'Description is too long');
this.invalidate();
}
},
password(model) {
let isPrivate = model.get('isPrivate');
let password = model.get('password');
if (isPrivate && password === '') {
model.get('errors').add('password', 'Password must be supplied');
this.invalidate();
}
}
});