mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
ac9f269085
closes #3153 - this is all about the validation engine - add a option, `opts.model`, to use a passed-in model directly if needed - handle validators that return an array of strings, array of objects, or both - ajax util returns either an array of errors or a single concat'd string - remove formatErrors function from the mixin and make it private - allow validation options to be passed into `.save()` since ember-data doesn't take params on `.save()` anyway - streamline control flow
29 lines
746 B
JavaScript
29 lines
746 B
JavaScript
var SignupValidator = Ember.Object.create({
|
|
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 || '', 1)) {
|
|
validationErrors.push({
|
|
message: 'Please enter a password.'
|
|
});
|
|
}
|
|
|
|
return validationErrors;
|
|
}
|
|
});
|
|
|
|
export default SignupValidator;
|