Skip to content

Support regexp capture group for rename  #1403

@rokoroku

Description

@rokoroku

Context

  • joi version: 13.1.0

What are you trying to achieve or the steps to reproduce ?

const schema = Joi.object().rename(/^someprefix-(\w+)$/g, '$1', { ignoreUndefined: true, multiple: true });
schema.validate({ 'someprefix-A': 1, 'someprefix-B': 2 }, { convert: true });

Which result you had ?

{ '$1': 1, 'someprefix-B': 2 }

renaming by capture group is not work.

What did you expect ?

from supports regexp, so why not add support capturing group to to parameter?

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