Skip to content

Change object.rename() override option to not delete existing if nothing match #1886

@hueniverse

Description

@hueniverse

Previously, this:

const schema = Joi.object().rename('a', 'b', { override: true });
const object = { b: 1 };

Would result in b being removed from the object because no a was found. This is unexpected behavior. If there is a real use case for this, we need another flag that means "only allow b from the rename, otherwise remove" which is by itself very odd. A better logic would be to forbid b unless it is from the rename.

Either way, I am changing this and if there is real need for the existing behavior, we can look into the proper way to support it.

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codebugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions