Joi 对象键类型
Joi object key type
我有带动态字符串键和字符串值的对象,
{
[string]: string
}
我该怎么做?
Joi.object().keys({
[Joi.string()]: Joi.string()
})
不工作:(
您想使用 Joi.object().pattern()。从 Joi 文档中,您可以提供:
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()
)
我有带动态字符串键和字符串值的对象,
{
[string]: string
}
我该怎么做?
Joi.object().keys({
[Joi.string()]: Joi.string()
})
不工作:(
您想使用 Joi.object().pattern()。从 Joi 文档中,您可以提供:
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()
)