Closed Juansu01 closed 1 year ago
That's not a joi issue but likely a hapi misuse. hapi prevents echo attacks by default, so it hides validation errors behind a generic one. If you know you're safe, you can throw the real error in a failAction: https://runkit.com/embed/nehziyxjalau
I see, thank you so much, I got the expected behavior
Support plan
Context
How can we help?
I'm validating a parameter inside the path, and I want to send this message as a response whenever I get a negative id "Id must be positive." I have set the custom message inside like this
.messages({"number.positive":"Id must be positive"})
but whenever the server gets a negative id, it returns the default "Invalid request params input" message. Is the schema wrong? Here's the full schema. I also know I'm using the right error code, I got it after logging it from a function I passed to.error()
I'm also validating the payload from a separate route, and it works, but I don't know why it does work here.