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

feat: Add dict to nativeEnum type #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hufftheweevil
Copy link

Great simple library!

Any interest in adding a dict property to nativeEnum types?

@hufftheweevil hufftheweevil changed the title Add dict to nativeEnum type feat: Add dict to nativeEnum type Feb 11, 2024
Copy link
Owner

@StefanTerdell StefanTerdell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a bad idea, but I'd like non-standard keywords to be opt-in, like with markdownDescription. I believe AJV will throw an error unless configured to allow them for example. A more descriptive prop name would probably be preferable as well.

Also include a mention in the readme. It's fine if it's just in the options table.

Add a couple of tests while you're at it.

@hufftheweevil
Copy link
Author

Any suggestions for a more descriptive prop? dictionary lookup lookupMap?

@StefanTerdell
Copy link
Owner

enumMap perhaps?

I was thinking though, maybe it's enough to just include the keys? Like

return {
  ...
  enum: ...,
  enumKeys: actualKeys
}

They should be in the same order making it possible to construct it on the other end.

Object.fromEntries(schema.enum((value, index) => [schema.enumKeys[index], value]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants