As id is assigned by db, I leave it optional. But later when I verify data come back from db. I want to check it is included in the data.
So, I defined a custom rule for this, which looks like
What I'm expecting is that an error reported for missing 'id'.
What was the result you got?
I actually get a validation error, but the message is "value" is required.
I checked the error details, key from local context is updated into error.details.context. But label is overridden by the root value.
What result did you expect?
The label defined in local context takes higher priority and shown in the error message. For the example case, the expecting message should "id" is required
Support plan
Context
What are you trying to achieve or the steps to reproduce?
I have a joi schema like
As id is assigned by db, I leave it optional. But later when I verify data come back from db. I want to check it is included in the data. So, I defined a custom rule for this, which looks like
What I'm expecting is that an error reported for missing 'id'.
What was the result you got?
I actually get a validation error, but the message is
"value" is required
. I checked the error details,key
from local context is updated intoerror.details.context
. Butlabel
is overridden by the root value.What result did you expect?
The label defined in local context takes higher priority and shown in the error message. For the example case, the expecting message should
"id" is required