Ghost/ghost/admin/app/validators/new-user.js
Austin Burdine 2a55c5767f Bower => NPM (#972)
no issue

- Convert validator to an npm dependency
  - clean up validator imports
  - fix validator function imports
  - remove unused validator extensions
- Convert devicejs to an npm dependency
- Convert remaining used bower deps to npm deps
- 🔥 Remove bower & unused bower dependencies
- remove globals imports in favor of direct module imports where possible
2018-03-19 17:56:09 +00:00

36 lines
968 B
JavaScript

import PasswordValidator from 'ghost-admin/validators/password';
import validator from 'npm:validator';
import {isBlank} from '@ember/utils';
export default PasswordValidator.extend({
init() {
this._super(...arguments);
this.properties = this.properties || ['name', 'email', 'password'];
},
name(model) {
let name = model.get('name');
if (!validator.isLength(name || '', 1)) {
model.get('errors').add('name', 'Please enter a name.');
this.invalidate();
}
},
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();
}
},
password(model) {
this.passwordValidation(model);
}
});