Comments (6)
Great question. This issue may give you some context.
At the time I built this module, they didn't allow other implementations to be used within the validate config.
With that said, I actually wouldn't mind changing the module to use the built in validate config, but I just haven't had time to update it.
from ratify.
Understood. Thanks!
from ratify.
With this ticket closed does that mean you won't end up moving to the built in config? Or will that go into a new ticket?
from ratify.
I was going to create a new one, but I'll actually just leave this one open for some additional context
from ratify.
Hi,
I tried to write a plugin which would check if object given to config.validate
is a JSON schema and act according to, but I failed. How is it possible even in latest version of Hapi? (v11.1.2 as of this message is written)
From hapi.js /lib/route.js line: 260
internals.compileRule = function (rule) {
// null, undefined, true - anything allowed
// false - nothing allowed
// {...} - ... allowed
return (rule === false ? Joi.object({}).allow(null)
: typeof rule === 'function' ? rule
: !rule || rule === true ? null // false tested earlier
: Joi.compile(rule));
};
If you provide JSON schema as an object to standard config.validate.payload
etc. of a route, hapi directly tries to convert it to JOI object. This is also clearly stated in API docs of hapi. As a result you cannot access bare JSON schema even in onPostAuth
, since it is already converted as below:
{ options: {},
params:
{ isJoi: true,
_type: 'object',
_settings: null,
_valids: { _set: [] },
_invalids: { _set: [] },
_tests: [],
_refs: [],
_flags: {},
_description: null,
_unit: null,
_notes: [],
_tags: [],
_examples: [],
_meta: [],
_inner:
{ children: [Object],
renames: [],
dependencies: [],
patterns: [] } },
payload: null,
headers: null,
query: null }
I will also open a ticket about this in hapi repository, but I will appreciate if you suggest any ideas how to achieve this in current version?
from ratify.
For update. I asked in hapi repository and got an answer. It seems impossible according to hapijs/hapi#2967.
from ratify.
Related Issues (20)
- Include error description (if any) in when reporting validation errors HOT 2
- Include field information in errors HOT 2
- Update to support Hapi 7.x.x HOT 2
- Make use of `validator.lastReport` if ` !validator.validateSchema(validationSchema))` fails.
- Should query string parameters be converted to the specified type before validating? HOT 3
- Update to Hapi 8.x.x HOT 5
- Upgrade dependency: z-schema HOT 1
- Consider migrating to pandastrike/jsck HOT 4
- Add a swagger hook to filter routes
- remove array query string parsing? HOT 1
- findPackageJson in SwaggerManager.js loops infinitely when used in iron-node HOT 1
- how to use references
- Global sample rate for response validation
- Getting invalid register options error HOT 1
- swagger-js-codegen not working on api doc root
- Node v6 - TypeError thrown when validating parsed querystring objects HOT 3
- Convert strings formatted as date-time to Date objects?
- Documentation to register plugin with options is not accurate for Hapi 6.x.x
- Is there a reason why response validation requires an object? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ratify.