Skip to content

Add a key validator with Joi objects #1382

@pierreis

Description

@pierreis

Currently, Joi only allows validating the unknown keys of an object using a regexp. While a good solution, it does adapt to more complex use-cases that would be better served by a Joi object.

For example, for email or uuid-like keys, I need to put a regex. This is sad as native validation already exists in Joi for these use-cases.

I would propose accepting as first argument a Joi string validator, while keeping the current behavior for compatibility.


The result would be: Joi.object().pattern(Joi.string().email(), Joi.any())

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions