How to handle hapi validation errors?
How to handle hapi validation errors? I have following route code for hapi... const routeConfig = { method: 'POST', path: '/user', config: { validate: { payload: { firstName: Joi.string().required(), } }, handler } } So when I don't pass the firstName it throws error like this firstName { "statusCode": 400, "error": "Bad Request", "message": "child "firstName" fails because ["firstName" is required]", "validation": { "source": "payload", "keys": [ "firstName" ] } } Now, I need to handle the above error in catch const handler = async(request, reply) => { try { const payload = request.payload const createUser = await User.create(payload) let token = Helpers.createJwt(createUser) reply({ success: true, message: 'User created succes...
