Skip to content

Joi 1.16 update : Error: requires a joi schema object #57

Description

@HugoHeneault

While trying to convert my joi schema to JSON I got an error : AssertionError [ERR_ASSERTION]: requires a joi schema object

Here is my code :

import * as Joi from "@hapi/joi";

const convert = require("joi-to-json-schema");

const  report = Joi.object({
      part: Joi.string()
          .valid(['a', 'b', 'c'])
          .required(),
     })

convert(report);

This seems to be related to hapijs/joi#1834

We should use Joi.isSchema() instead.

I will try to provide a PR using isSchema when available then fallback to isJoi if it's OK for you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions