Open
Description
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 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
:Lines 330 to 385 in 239ec33
Activity