Skip to content

A better way to communicate mismatching Joi versions #3088

@damusix

Description

@damusix

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions