Cannot get the flag/presence of a property
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): yes
* *is this issue affecting a production system?* (yes/no): no
#### Context
* *node version*: v16.14.0
* *module version with issue*: v17.9.2
* *last module version without issue*: N/A
* *environment* (e.g. node, browser, native): browser
* *used with* (e.g. hapi application, another framework, standalone, ...): react-hook-form resolver for joi
* *any other relevant information*: N/A
#### What are you trying to achieve or the steps to reproduce?
I'm trying to get the presence of a field. So, trying to learn if presence is optional or required. In order to get that I'm using `$_getFlag` but it doesn't work.
#### What was the result you got?
Works:
```js
console.log('1. firstName', sampleFormSchema.extract('firstName')._flags.presence);
```
Works:
```js
console.log('2. firstName', sampleFormSchema.$_terms.keys.find((key) => key.key === 'firstName')?.schema._flags.presence);
```
Doesn't Work:
```js
console.log('3. firstName', sampleFormSchema.$_getFlag('firstName'));
console.log('3. firstName', sampleFormSchema.$_getFlag('firstName', 'presence'));
```
#### What result did you expect?
Expected to receive 'option' or 'required' but received undefined.
Contributor guide
Assessment
This issue has not been assessed yet.