hapijs / hapijs/joi

Is it possible to override or remove behavior from a field?

Open
#2,929 2 comments 0 reactions 1 assignee Claimed by @Marsup View on GitHub
support
Dominant language
JavaScript
Stars
21.2k
Forks
1.5k
Avg merge
4h 57m
Merged PRs (30d)
14

Description

Let's say I have the following schema:

```

const schema = Joi.object().keys({
withDefault: Joi.string().default(3),
array: Joi.array().items(1,2),
});
```

I wonder if it's possible to delete the default value from the `withDefault` field when extending it, for instance doing:
`schema.extract("withDefault").default()` so that the default is reset to no default value.

And then for the array, I wonder if it's also possible to override the list of possible items, let's say instead of 1 and 2, I want the list to be 2, 3 and 4.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.