Last active
December 17, 2015 23:09
-
-
Save calmdev/5687025 to your computer and use it in GitHub Desktop.
Revisions
-
calmdev revised this gist
May 31, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ user.validate().success(function() { }); }); // Still trying to get this isUnique validation method working on my model: email: { type: DataTypes.STRING, validate: { @@ -26,7 +26,7 @@ email: { // When the isUnique is added to my model, calling .validate(); generates: Error: Email is already registered. at null.<anonymous> (/Web/models/User.js:82:13) at EventEmitter.emit (events.js:95:17) at null.<anonymous> (/Code/sequelize/lib/query-interface.js:392:17) at EventEmitter.emit (events.js:117:20) -
calmdev revised this gist
May 31, 2013 . 1 changed file with 32 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,38 @@ // This validation check works: user.validate().success(function() { user.save().success(function(user){ console.log(user); }).error(function(errors) { console.log(errors); }); }); // Still trying to get this validation method working on my model: email: { type: DataTypes.STRING, validate: { isEmail: { msg: 'Invalid email address.' }, isUnique: function(value) { app.get('MODELS').User.find({ where: { email: value } }).success(function(account) { throw new Error('Email is already registered.'); // Alone, this line works fine. }); } } } // When the isUnique is added to my model, calling .validate(); generates: Error: Email is already registered. at null.<anonymous> (/Web/api.grooptrip.com/models/User.js:82:13) at EventEmitter.emit (events.js:95:17) at null.<anonymous> (/Code/sequelize/lib/query-interface.js:392:17) at EventEmitter.emit (events.js:117:20) at null.<anonymous> (/Code/sequelize/lib/dialects/mysql/query.js:32:14) at Query.Sequence.end (/Code/sequelize/node_modules/mysql/lib/protocol/sequences/Sequence.js:66:24) at Query._handleFinalResultPacket (/Code/sequelize/node_modules/mysql/lib/protocol/sequences/Query.js:143:8) at Query.EofPacket (/Code/sequelize/node_modules/mysql/lib/protocol/sequences/Query.js:127:8) at Protocol._parsePacket (/Code/sequelize/node_modules/mysql/lib/protocol/Protocol.js:172:24) at Parser.write (/Code/sequelize/node_modules/mysql/lib/protocol/Parser.js:62:12) -
calmdev created this gist
May 31, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ user.validate().success(function() { user.save().success(function(user){ console.log(user); }).error(function(errors) { console.log(errors); }); });