Closed hyoretsu closed 3 years ago
I don't think I understand the question. Segments.BODY
is to help people write schemas and not have to use the string "body"
etc. I'm not sure what you are asking about a body
property on celebrate
? Even if IntelliSense says it's there, it not part of the public API regardless.
Asking if there's any difference between using this
celebrate({
[Segments.BODY]: {
id: Joi.string().required(),
},
}),
or this, as IntelliSense pointed out. (When body is set, joi will validate req.body with the supplied schema.)
celebrate({
body: {
id: Joi.string().required(),
},
}),
When I changed the former to the latter, everything looked like it's working just fine. Even though most people and the docs use [Segments.BODY]
No, there would be no functional difference in those two styles.
Oh, great. Tyvm
I first learned to use it with Segments.BODY, the docs use it and a lot of project also use it. But I recently found out using IntelliSense that celebrate() has a body property that checks req.body, and it seems to work just the same as my previous implementaion.
Is there any actual difference between the two?