Ghost/ghost/admin/app/validators/invite-user.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

30 lines
803 B
JavaScript

import BaseValidator from './base';
import validator from 'validator';
import {isBlank} from '@ember/utils';
export default BaseValidator.create({
properties: ['email', 'role'],
email(model) {
let email = model.get('email');
if (isBlank(email)) {
model.get('errors').add('email', 'Please enter an email.');
this.invalidate();
} else if (!validator.isEmail(email)) {
model.get('errors').add('email', 'Invalid Email.');
this.invalidate();
}
},
role(model) {
let role = model.get('role');
if (isBlank(role)) {
model.get('errors').add('role', 'Please select a role.');
model.get('hasValidated').pushObject('role');
this.invalidate();
}
}
});