Skip to content

Extending a schema #710

@bsiddiqui

Description

@bsiddiqui

Is there a way to overwrite a key in the schema or add to the validation parameter?

Overwrite a key:

var base = Joi.object().keys({
    a: Joi.number(),
    b: Joi.string()
});

var extended = base.keys({
    a: Joi.string()
});

Add a parameter:

var base = Joi.object().keys({
    a: Joi.number(),
    b: Joi.string()
});

var extended = base.keys({
    a: Joi.number().min(10)
});

Metadata

Metadata

Assignees

Labels

bugBug or defectsupportQuestions, discussions, and general support

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions