-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Context
- node version: *
- joi version: 13.1.2
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
What are you trying to achieve or the steps to reproduce ?
Describe your issue here, include schemas and inputs you are validating if needed.
const schema = Joi.string().example(123);Which result you had ?
Constant schema is set to a valid schema object.
What did you expect ?
Error to be thrown
Description
I've been using the .example method everywhere on pretty much every schema that I've ever created as it gives us the flexibility of producing documentation but also use it as a cheap and easy way of unit testing.
Now, as per #1189, it was decided that this would just be taken out. It wasn't even thought useful to document the change (the documentation still says that it should throw) let alone marked as a breaking change.
Can this be put back the way it was and maybe some more thought could be put into the issue such as allowing the example to take a second argument of an option object that could take:
- A
refproperty. What is the point of having an example without ref data anyway when it requires aref? - A
validateproperty that would validate the example or not and make ittrueby default.
By the way, I absolutely love the Joi project and I've recommending it to developers ever since I found it. This particular piece of functionality has been one of the main selling points I've used when pushing it onto people.
Thanks in advance,