A better way to communicate mismatching Joi versions
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
### Runtime
NodeJS
### Runtime version
22
### Module version
18
### Used with
Hap, other
### Any other relevant information
This is the 3rd time this happens to me. It's probably a bit nuanced, but it's annoying and very time consuming:
Every time that I have two applications or two libraries that use different Joi versions, I have to go into the node modules and do some console logging before I know what schema is presenting the problem.
I've resorted to this for debugging:
```ts
exports.isSchema = function (schema, options = {}) {
const any = schema && schema[exports.symbols.any];
if (!any) {
return false;
}
if (any.version !== exports.version) {
// Console log the schema:
console.log(schema);
// Console log the schema description— which would error with my schemas sometimes for some reason:
console.log(schema.describe());
}
Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');
return true;
};
```
Tracing is useless because it always points to Joi.
At least, with logging of schema or schema description, I can see what's being validated and get a clearer picture.
I don't know if this is valuable to anyone else, but this is the 3rd time I spend 1 to 2 hours solving this same problem. It can be shorted by better user feedback.
### What problem are you trying to solve?
Spending hours dicovering where the mismatching Joi version is
### Do you have a new or modified API suggestion to solve the problem?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.