2015-06-07 06:19:19 +03:00
|
|
|
import BaseValidator from './base';
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-08-19 14:55:40 +03:00
|
|
|
export default BaseValidator.extend({
|
2015-06-07 06:19:19 +03:00
|
|
|
properties: ['name', 'email', 'password'],
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
name(model) {
|
|
|
|
let name = model.get('name');
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-06-07 06:19:19 +03:00
|
|
|
if (!validator.isLength(name, 1)) {
|
|
|
|
model.get('errors').add('name', 'Please enter a name.');
|
|
|
|
this.invalidate();
|
2014-07-25 23:17:16 +04:00
|
|
|
}
|
2015-06-07 06:19:19 +03:00
|
|
|
},
|
2015-10-28 14:36:45 +03:00
|
|
|
|
|
|
|
email(model) {
|
|
|
|
let email = model.get('email');
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-07-07 20:34:23 +03:00
|
|
|
if (validator.empty(email)) {
|
|
|
|
model.get('errors').add('email', 'Please enter an email.');
|
|
|
|
this.invalidate();
|
|
|
|
} else if (!validator.isEmail(email)) {
|
2015-06-07 06:19:19 +03:00
|
|
|
model.get('errors').add('email', 'Invalid Email.');
|
|
|
|
this.invalidate();
|
2014-07-25 23:17:16 +04:00
|
|
|
}
|
2015-06-07 06:19:19 +03:00
|
|
|
},
|
2015-10-28 14:36:45 +03:00
|
|
|
|
|
|
|
password(model) {
|
|
|
|
let password = model.get('password');
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-06-07 06:19:19 +03:00
|
|
|
if (!validator.isLength(password, 8)) {
|
|
|
|
model.get('errors').add('password', 'Password must be at least 8 characters long');
|
|
|
|
this.invalidate();
|
|
|
|
}
|
2014-07-25 23:17:16 +04:00
|
|
|
}
|
|
|
|
});
|