mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
a22dca8722
No issue - Created NewUserValidator class to DRY up validation of a models name, email, and password - Changed SignUpValidator to be an instance of NewUserValidator - Changed SetUpValidator to extend NewUserValidator
29 lines
756 B
JavaScript
29 lines
756 B
JavaScript
var NewUserValidator = Ember.Object.extend({
|
|
check: function (model) {
|
|
var data = model.getProperties('name', 'email', 'password'),
|
|
validationErrors = [];
|
|
|
|
if (!validator.isLength(data.name, 1)) {
|
|
validationErrors.push({
|
|
message: 'Please enter a name.'
|
|
});
|
|
}
|
|
|
|
if (!validator.isEmail(data.email)) {
|
|
validationErrors.push({
|
|
message: 'Invalid Email.'
|
|
});
|
|
}
|
|
|
|
if (!validator.isLength(data.password, 8)) {
|
|
validationErrors.push({
|
|
message: 'Password must be at least 8 characters long.'
|
|
});
|
|
}
|
|
|
|
return validationErrors;
|
|
}
|
|
});
|
|
|
|
export default NewUserValidator;
|