Added missing client validations for blog title and user/subscriber email fields (#909)

refs TryGhost/Ghost#8143

Added more client side validations for input fields:

- Blog title in setup flow (150 chars)
- User email (191 chars)
- Subscribers email (191 chars)
This commit is contained in:
Aileen Nowak 2017-11-16 20:47:56 +08:00 committed by Kevin Ansfield
parent d028b5a5b9
commit 18614c39f6
3 changed files with 14 additions and 0 deletions

View File

@ -10,5 +10,10 @@ export default NewUserValidator.create({
model.get('errors').add('blogTitle', 'Please enter a blog title.'); model.get('errors').add('blogTitle', 'Please enter a blog title.');
this.invalidate(); this.invalidate();
} }
if (!validator.isLength(blogTitle, 0, 150)) {
model.get('errors').add('blogTitle', 'Title is too long');
this.invalidate();
}
} }
}); });

View File

@ -14,6 +14,10 @@ export default BaseValidator.create({
model.get('errors').add('email', 'Invalid email.'); model.get('errors').add('email', 'Invalid email.');
model.get('hasValidated').pushObject('email'); model.get('hasValidated').pushObject('email');
this.invalidate(); this.invalidate();
} else if (!validator.isLength(email, 0, 191)) {
model.get('errors').add('email', 'Email is too long');
model.get('hasValidated').pushObject('email');
this.invalidate();
} }
} }
}); });

View File

@ -40,6 +40,11 @@ export default PasswordValidator.create({
model.get('errors').add('email', 'Please supply a valid email address'); model.get('errors').add('email', 'Please supply a valid email address');
this.invalidate(); this.invalidate();
} }
if (!validator.isLength(email, 0, 191)) {
model.get('errors').add('email', 'Email is too long');
this.invalidate();
}
}, },
location(model) { location(model) {