Skip to content

Instantly share code, notes, and snippets.

@glesage
Created January 20, 2015 06:11
Show Gist options
  • Save glesage/0637495face9dc21ca82 to your computer and use it in GitHub Desktop.
Save glesage/0637495face9dc21ca82 to your computer and use it in GitHub Desktop.
Zipcode
// 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