Created
September 30, 2014 18:37
-
-
Save alanhoff/4b963a1b2d11615c3e11 to your computer and use it in GitHub Desktop.
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 characters
| var user = require('./userSchema'); | |
| user.validate({password: 'alan', email: 'huehue@br.br'}, function(err, data){ | |
| if(err) | |
| throw err; | |
| //gravar o data no banco de dados | |
| db.insert(data); | |
| }); |
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 characters
| var Joi = require('joi'); | |
| var schema = Joi.object().keys({ | |
| attributes: Joi.object(), | |
| password: Joi.string().regex(/[a-zA-Z0-9]{3,30}/), | |
| email: Joi.string().email() | |
| }).with('email', 'attributes').without('password'); | |
| module.exports = { | |
| validate: function(data, callback){ | |
| Joi.validate(data, schema, callback); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment