Skip to content

failover() support for default on errors #1535

@WesTyler

Description

@WesTyler

Describe the problem you are trying to fix (provide as much context as possible)

From the discussion here:
per @genediazjr

I'm thinking of an API for Joi that would allow a default value similar to any.default() but only if the original value is invalid. The value key on the error object will contain the set infInvalid value instead of the original value. Or we can put it on separate key whichever would be better.

Which API (or modification of the current API) do you suggest to solve that problem ?

I would like to propose adding an optional config param to .default():

Joi.string().default('name', { invalid: true })

Are you ready to work on a pull request if your suggestion is accepted ?

Yes.

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