You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for long post. As documented, route's config.validate.xxx expects a function, true, false or a Joi validation object. Other validation plugins such as JSON schema validators etc. need to provide a function and options key, or plugin details in route config.
Reading #1039 I would like to write JSON schema validator plugin and let users provide schema in validate section as below:
Providing JSON schema as an object to config.validate.param, hapi converts it to Joi object (even it is not a Joi object) which is expected as seen hapi's API docs. As a result you cannot access bare JSON schema even in onPostAuth, since it is already converted as below:
Unlikely to happen, anything in javascript is a valid joi object. Your best bet is to put your stuff in the plugins part of the route and have your plugin process that.
Hi,
Sorry for long post. As documented, route's
config.validate.xxx
expects a function,true
,false
or a Joi validation object. Other validation plugins such as JSON schema validators etc. need to provide a function and options key, or plugin details in route config.Reading #1039 I would like to write JSON schema validator plugin and let users provide schema in validate section as below:
However it is not possible to write a plugin which would use
config.validate
with an object.hapi/lib/route.js line: 260
Providing JSON schema as an object to
config.validate.param
, hapi converts it to Joi object (even it is not a Joi object) which is expected as seen hapi's API docs. As a result you cannot access bare JSON schema even inonPostAuth
, since it is already converted as below:My question is: How to not to touch
config.validate
object if it is not a valid Joi object?If this isn't possible yet, I would gladly make a pull request to hapi. However IMHO this also touches Joi.
My backwards compatible suggestion for hapi would be using an imaginative method from Joi.
hapi/lib/route.js line: 260
hapi/lib/validation.js line: 130
I can't think of an efficient way for this imaginative
Joi.isValidJoiObject
method. Perhaps @Marsup would suggest.The text was updated successfully, but these errors were encountered: