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
The default serialization of values using template {#value} does not match our expected outcomes. I was looking for a way to improve it (by relying on require('node:utils').inspect.
I've tried using expressions only to switch formatting depending on value (I want to quote strings, but not int, and do this deeply within objects/array). For object, it resulted in [object Object]
I've tried to declare global functions I could use in expression without passing it explicitly everytime.
I ended up doing Joi.expression('{#label} expected to be ..., have {inspectValue(#value)}', { inspectValue(value) { return inspect(value) }}) for every overridden message. It works, but requires a lot of boilerplate code for something I'd like to make available for the whole app.
Do you have a new or modified API suggestion to solve the problem?
Add a method to declare template functions available for every expressions
Or add a way to customize Template's internal.stringify:
Runtime
NodeJS
Runtime version
22
Module version
17.13.3
Used with
Standalone
Any other relevant information
No response
What problem are you trying to solve?
The default serialization of values using template
{#value}
does not match our expected outcomes. I was looking for a way to improve it (by relying onrequire('node:utils').inspect
.[object Object]
Joi.expression('{#label} expected to be ..., have {inspectValue(#value)}', { inspectValue(value) { return inspect(value) }})
for every overridden message. It works, but requires a lot of boilerplate code for something I'd like to make available for the whole app.Do you have a new or modified API suggestion to solve the problem?
internal.stringify
:joi/lib/template.js
Lines 330 to 385 in 239ec33
The text was updated successfully, but these errors were encountered: