joi icon indicating copy to clipboard operation
joi copied to clipboard

Remove ValidationError.annotate() from browser build

Open hueniverse opened this issue 6 years ago • 6 comments

hueniverse avatar Jan 04 '20 05:01 hueniverse

With 17.0.2 I get Error: Error annotation is not supported when Joi.assert validation error occurs in the browser. I couldn't find any mention of it outside of this issue and linked release notes. The validation error message is fine in 16.1.8.

adambuczek avatar Jan 18 '20 19:01 adambuczek

I’m confused. It’s clearly documented exactly where it should be. What’s the issue?

hueniverse avatar Jan 18 '20 22:01 hueniverse

Sorry, I (grossly) misunderstood this issue. Is there another of getting validation error details when using browser build? Should I supply my own annotate implementation?

adambuczek avatar Jan 19 '20 00:01 adambuczek

The annotate method is used mostly for displaying pretty errors in CLI tools. The error you get already includes all the information you need to handle it programmatically. Why do you need to annotate errors for console display in the browser?

hueniverse avatar Jan 19 '20 01:01 hueniverse

I don't. This is not something I do manually. When used like this:

try {
  Joi.assert(…)
} catch(e) {
  debugger
}

Annotate is being called internally so the error I get is not the ValidationError instance but the error resulting from trying to call ValidationError.annotate. Is assert not the intended method in such case (in browser)?

adambuczek avatar Jan 19 '20 08:01 adambuczek

Got it! I'll get that fixed.

hueniverse avatar Jan 19 '20 16:01 hueniverse