2014-06-25 07:12:48 -05:00
|
|
|
var SetupValidator = Ember.Object.create({
|
2014-06-29 22:43:25 -05:00
|
|
|
check: function (model) {
|
2014-06-25 07:12:48 -05:00
|
|
|
var data = model.getProperties('blogTitle', 'name', 'email', 'password'),
|
|
|
|
validationErrors = [];
|
|
|
|
|
2014-07-15 14:52:44 -05:00
|
|
|
if (!validator.isLength(data.blogTitle, 1)) {
|
2014-06-25 07:12:48 -05:00
|
|
|
validationErrors.push({
|
|
|
|
message: 'Please enter a blog title.'
|
|
|
|
});
|
|
|
|
}
|
2014-06-29 22:43:25 -05:00
|
|
|
|
2014-07-15 14:52:44 -05:00
|
|
|
if (!validator.isLength(data.name, 1)) {
|
2014-06-25 07:12:48 -05:00
|
|
|
validationErrors.push({
|
|
|
|
message: 'Please enter a name.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validator.isEmail(data.email)) {
|
|
|
|
validationErrors.push({
|
|
|
|
message: 'Invalid Email.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-07-15 14:52:44 -05:00
|
|
|
if (!validator.isLength(data.password, 8)) {
|
2014-06-25 07:12:48 -05:00
|
|
|
validationErrors.push({
|
2014-07-15 14:52:44 -05:00
|
|
|
message: 'Password must be at least 8 characters long.'
|
2014-06-25 07:12:48 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return validationErrors;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default SetupValidator;
|