You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are you trying to achieve or the steps to reproduce ?
Pretty straightforward, take a thing or an array of that thing, with a sane failure message:
Joi.alternatives()
.try(notificationsArray, notification)
.error(new Error('Either a valid notification or non-empty notification array is required')),
The actual definition of notification and notificationArray aren't important, but they are something to the effect of:
"error": [
{
"message": "\"value\" must be an array",
"path": "value",
"type": "array.base",
"context": {
"key": "value"
}
},
{
"message": "\"notifications\" is not allowed",
"path": "notifications",
"type": "object.allowUnknown",
"context": {
"child": "notifications",
"key": "notifications"
}
}
]
What did you expect ?
"error": "Either a valid notification or non-empty notification array is required"
This is especially relevant for alternatives because they produce such ... unfriendly error output that you really need to override it, if you want your API consumers to have any idea what they did wrong.
The text was updated successfully, but these errors were encountered:
Context
What are you trying to achieve or the steps to reproduce ?
Pretty straightforward, take a thing or an array of that thing, with a sane failure message:
The actual definition of
notification
andnotificationArray
aren't important, but they are something to the effect of:Then just validate with a garbage value like
''
.What was your result?
What did you expect ?
This is especially relevant for
alternatives
because they produce such ... unfriendly error output that you really need to override it, if you want your API consumers to have any idea what they did wrong.The text was updated successfully, but these errors were encountered: