Closed ghost closed 3 years ago
Why would you close ? Joi juste merged my PR, I will create a celebrate PR for this issue.
I closed this because I thought the only change needed to happen was in Joi, which landed.
Can we reopen this issue? I am going to create a PR for this. I think this will be very useful feature
node
version - 10.15celebrate
version - 13.0.4joi
version (vianpm ls --depth=0 | grep joi
) - 17.3.0@types/joi
version (vianpm ls --depth=0 | grep joi
) - 17.2.3I am concerned with the celebrate function typing. Any reason why you would not want to infer typing from arguments ? I see several benefits:
It would be better if celebrate inferred req.body type directly from the body argument. Same for query or params.
I had it working with the following fix:
You can see in the attached picture that typing is inferred correctly based on body arguments provided.
Only downside: I had to make a small change to Joi types, to make Joi.Schema generic for ObjectSchema. But it should be very easy to make this change accepted because it's a seamless change:
Are you interested in a PR with those changes ?