I have object with dynamic string keys with string values,
{
[string]: string
}
how can I do this?
Joi.object().keys({
[Joi.string()]: Joi.string()
})
not working :(
I have object with dynamic string keys with string values,
{
[string]: string
}
how can I do this?
Joi.object().keys({
[Joi.string()]: Joi.string()
})
not working :(
You want to use Joi.object().pattern(). From the Joi docs, this lets you provide:
A pattern that can be either a regular expression or a joi schema that will be tested against the unknown key names.
const schema = Joi.object().pattern(
Joi.string(), Joi.string()
)