Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joi when require is #47

Open
throrin19 opened this issue May 3, 2019 · 0 comments
Open

Joi when require is #47

throrin19 opened this issue May 3, 2019 · 0 comments

Comments

@throrin19
Copy link

I have a problem with Joi When usage.

the when must be use with 2 cases :

  • Directly with other object field
  • With specific Joi schema

The problem with the second type. For example I have this schema :

Joi.when(Joi.object({ type : 'model' }).unknown(), {
    then        : Joi.object().keys(modelObject),
    otherwise   : Joi.object().keys(mathObject),
})

This schema switch full result schema when one specific field has specific value.

In my case, I can't use the is option but your library force this option and ignore the second when use case.

If I comment this part it works fine :

if (!match.is) {
throw new Error('joi.when requires an "is"');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant