config: {
validate: {
params: { id: Joi.string().valid(Joi.ref('$auth.credentials.sub')) }
}
},
message: '"id" must be one of [context:auth.credentials.sub]',
this._path = v.replace(/\/$/, '');
^
TypeError: v.replace is not a function
server.route({
method: 'GET',
path:'/users',
config: {
tags: ['api'],
description: 'Get all users',
notes: 'Returns all users'
},
handler:(request, h) => {
// let data = '';
connection.query('SELECT * FROM users', (error, results, fields) => {
if (error) throw error;
console.log(results);
});
return results;
}
});
server.route.settings.validate
when you create the server (or in a ‘manifest’ file if you use glue as I do). In the example you gave, you are over writing the function each time a request comes in
Hi, I have a schema:taskRelatedContent: Joi.array()
.items(relatedContent)
.allow(null),
relatedContent translates to:const relatedContent = Joi.object().keys({
contentId: Joi.string(),
lang: Joi.array(),
displayName: Joi.string(),
url: Joi.string(),
mimeType: Joi.string(),
});
For some reason, the Joi.validate fails saying:
"ValidationError: child \"taskRelatedContent\" fails because [\"taskRelatedContent\" at position 0 fails because [\"contentId\" is not allowed, \"lang\" is not allowed, \"displayName\" is not allowed, \"url\" is not allowed, \"mimeType\" is not allowed]]\n
There is obviously something mighty obvious in here, that is causing this.
Pulling my hairs to see what. Does anyone else see what I am doing wrong in here?
we used to have style.md for the style guide. Now I can only find https://github.com/hapijs/eslint-plugin-hapi
Is the style defined somewhere or is this what we have ?