2016-05-24 15:06:59 +03:00
|
|
|
import NewUserValidator from 'ghost-admin/validators/new-user';
|
2019-01-22 16:09:38 +03:00
|
|
|
import validator from 'validator';
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-08-19 14:55:40 +03:00
|
|
|
export default NewUserValidator.create({
|
2017-09-04 22:17:04 +03:00
|
|
|
properties: ['name', 'email', 'password', 'blogTitle'],
|
2014-06-25 16:12:48 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
blogTitle(model) {
|
|
|
|
let blogTitle = model.get('blogTitle');
|
2014-06-30 07:43:25 +04:00
|
|
|
|
2018-03-19 20:56:09 +03:00
|
|
|
if (!validator.isLength(blogTitle || '', 1)) {
|
2022-03-08 23:23:49 +03:00
|
|
|
model.get('errors').add('blogTitle', 'Please enter a site title.');
|
2015-06-07 06:19:19 +03:00
|
|
|
this.invalidate();
|
|
|
|
}
|
2017-11-16 15:47:56 +03:00
|
|
|
|
2018-03-19 20:56:09 +03:00
|
|
|
if (!validator.isLength(blogTitle || '', 0, 150)) {
|
2017-11-16 15:47:56 +03:00
|
|
|
model.get('errors').add('blogTitle', 'Title is too long');
|
|
|
|
this.invalidate();
|
|
|
|
}
|
2014-06-25 16:12:48 +04:00
|
|
|
}
|
2015-06-07 06:19:19 +03:00
|
|
|
});
|