mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
042aecb7f6
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)`
26 lines
864 B
JavaScript
26 lines
864 B
JavaScript
import BaseValidator from './base';
|
|
import validator from 'validator';
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
export default BaseValidator.create({
|
|
properties: ['email'],
|
|
|
|
email(model) {
|
|
let email = model.get('email');
|
|
|
|
if (isBlank(email)) {
|
|
model.get('errors').add('email', 'Please enter an email.');
|
|
model.get('hasValidated').pushObject('email');
|
|
this.invalidate();
|
|
} else if (!validator.isEmail(email)) {
|
|
model.get('errors').add('email', 'Invalid email.');
|
|
model.get('hasValidated').pushObject('email');
|
|
this.invalidate();
|
|
} else if (!validator.isLength(email, 0, 191)) {
|
|
model.get('errors').add('email', 'Email is too long');
|
|
model.get('hasValidated').pushObject('email');
|
|
this.invalidate();
|
|
}
|
|
}
|
|
});
|