mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
2a55c5767f
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
36 lines
968 B
JavaScript
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);
|
|
}
|
|
});
|