Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
small bug fix where Mongoose validation functions must always return …
Browse files Browse the repository at this point in the history
…booleans
  • Loading branch information
lirantal committed Jan 12, 2014
1 parent 969c691 commit 3963892
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ var validatePresenceOf = function(value) {
UserSchema.path('name').validate(function(name) {
// if you are authenticating by any of the oauth strategies, don't validate
if (!this.provider) return true;
return name.length;
return (typeof name === 'string' && name.length > 0);
}, 'Name cannot be blank');

UserSchema.path('email').validate(function(email) {
// if you are authenticating by any of the oauth strategies, don't validate
if (!this.provider) return true;
return email.length;
return (typeof email === 'string' && email.length > 0);
}, 'Email cannot be blank');

UserSchema.path('username').validate(function(username) {
// if you are authenticating by any of the oauth strategies, don't validate
if (!this.provider) return true;
return username.length;
return (typeof username === 'string' && username.length > 0);
}, 'Username cannot be blank');

UserSchema.path('hashed_password').validate(function(hashed_password) {
// if you are authenticating by any of the oauth strategies, don't validate
if (!this.provider) return true;
return hashed_password.length;
return (typeof hashed_password === 'string' && hashed_password.length > 0);
}, 'Password cannot be blank');


Expand Down

0 comments on commit 3963892

Please sign in to comment.