Breaking change with .extend()
The docs fail miserably at explaining how to extend Joi.
When you google how to create extensions for Joi there are hundreds of posts and libraries that have code just like the one posted in this issue.
This one in particular @meanie/joi-country has "Joi": "^17.0.0 " in it's package.json but the library doesn't even work with the current version 17.4.2.
Here's a codesanbox showing how it fails with .country is not a function: https://codesandbox.io/s/amazing-cerf-hwjo0?file=/src/index.js
Was there a breaking change without a major semver increase?
For future people who might be pulling their hair out, this is how you currently extend things:
https://codesandbox.io/s/naughty-thunder-d2hgu?file=/src/index.js
There are some important differences to the blog posts, issues and code you'll find plasteredd around online:
- The extend object uses the key
typenow, notname - You can't use the top level validate method, instead use
rules.myRule = { validate } - The validate method should now return a
helpers.error()not an object eg{ value, errors }