arb / celebrate

A joi validation middleware for Express.
MIT License
1.33k stars 66 forks source link

Curried celebrator does not work as described in docs #215

Closed jasmine-q closed 3 years ago

jasmine-q commented 3 years ago

Here is an example value that is not working as expected:

Running celebrator({ reqContext: true, mode: Modes.FULL }, { convert: false })(schema) results in:

ValidationError: {
  "convert" [1]: false
}

[1] "convert" is not allowed

Running celebrator({ reqContext: true, mode: Modes.FULL }, { convert: false }, schema) results in:

ValidationError: {
  "mode": "full",
  "reqContext" [1]: true
}

[1] "reqContext" is not allowed

However, celebrator({ reqContext: true, mode: Modes.FULL })({ convert: false })(schema) works!

The issue I am having with celebrate is:

celebrator isn't able to be used in all the ways listed in the docs:

let c = celebrator(opts)(joiOpts)(schema); // working
c = celebrator(opts, joiOpts)(schema); // does not work
c = celebrator(opts)(joiOpts, schema); // does not work
c = celebrator(opts, joiOpts, schema); // does not work
arb commented 3 years ago

It sure is!! Thanks for reporting. I've got a simple fix locally. I think I will make this a breaking change in case people were using it in the broken state before. What are your thoughts?

arb commented 3 years ago

Hey @jasmine-q, can you give #216 a spin when you get a minute? Does that solve your issue?

jasmine-q commented 3 years ago

Hey @jasmine-q, can you give #216 a spin when you get a minute? Does that solve your issue?

Hi @arb, sorry I didn't get back to you earlier. Yes that's working great for me and solves my issue, thanks for the quick reply and fix!

Making this a breaking change makes sense to me 👍