mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
d0c151be70
closes #5336 - creates gh-form-group component to handle form group status - refactors current validation methods to work on a per-property basis - adds gh-error-message component to render error message - removes (comments out) tests that pertain to the old notifications until the new inline validation is added
32 lines
893 B
JavaScript
32 lines
893 B
JavaScript
import BaseValidator from './base';
|
|
|
|
var NewUserValidator = BaseValidator.extend({
|
|
properties: ['name', 'email', 'password'],
|
|
|
|
name: function (model) {
|
|
var name = model.get('name');
|
|
|
|
if (!validator.isLength(name, 1)) {
|
|
model.get('errors').add('name', 'Please enter a name.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
email: function (model) {
|
|
var email = model.get('email');
|
|
|
|
if (!validator.isEmail(email)) {
|
|
model.get('errors').add('email', 'Invalid Email.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
password: function (model) {
|
|
var password = model.get('password');
|
|
|
|
if (!validator.isLength(password, 8)) {
|
|
model.get('errors').add('password', 'Password must be at least 8 characters long');
|
|
this.invalidate();
|
|
}
|
|
}
|
|
});
|
|
|
|
export default NewUserValidator;
|