Created
January 20, 2015 06:11
-
-
Save glesage/0637495face9dc21ca82 to your computer and use it in GitHub Desktop.
Zipcode
This file contains 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 characters
// Zipcode.json | |
{ | |
"name": "Zipcode", | |
"base": "PersistedModel", | |
"properties": { | |
"zipcode": { | |
"type": "string", | |
"required": true, | |
"length": 5 | |
} | |
}, | |
"validations": [], | |
"relations": {}, | |
"acls": [], | |
"methods": [] | |
} | |
// Zipcode.js | |
module.exports = function(Zipcode) | |
{ | |
Zipcode.beforeCreate = function(next, data) | |
{ | |
Zipcode.findOne({where: {zipcode: data.zipcode}}, function(err, result) | |
{ | |
if (err) return next(err); | |
if (result) return next(null, result); | |
return next(); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment