Created
January 30, 2017 18:05
-
-
Save samueljoli/dba973b2d8a2341113d40a07f749999d 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
| // assuming we are already defining Hapi server routes | |
| const payloadSchema = Joi.object().keys({ | |
| id : Joi.string().guid().required(), | |
| name : Joi.string().min(3).required(), | |
| callRequested: Joi.boolean().optional(), | |
| phoneNumber : Joi.when(‘callRequested’, { | |
| is : true, | |
| then : Joi.string().min(10).required(), | |
| otherwise: Joi.string().allow(null).optional() | |
| }) | |
| }); | |
| server.route({ | |
| method : 'POST', | |
| path : '/document', | |
| handler: plugin.post, | |
| config : { | |
| validate: payloadSchema | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment