Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get the flag/presence of a property #2976

Open
cyonder opened this issue Aug 17, 2023 · 0 comments
Open

Cannot get the flag/presence of a property #2976

cyonder opened this issue Aug 17, 2023 · 0 comments
Labels
support Questions, discussions, and general support

Comments

@cyonder
Copy link

cyonder commented Aug 17, 2023

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:

console.log('1. firstName', sampleFormSchema.extract('firstName')._flags.presence);

Works:

console.log('2. firstName', sampleFormSchema.$_terms.keys.find((key) => key.key === 'firstName')?.schema._flags.presence);

Doesn't Work:

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.

@cyonder cyonder added the support Questions, discussions, and general support label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

1 participant