We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It would be great to see support of enum values through to extracted types.
enum
I've just tested out the following code with the @latest tag of @hapi/joi & joi-extract-type and it appears they aren't carried through.
@latest
@hapi/joi
joi-extract-type
Are there any plans to support? Has it been looked at before?
import * as joi from '@hapi/joi'; import 'joi-extract-type'; enum Options { OPTION_ONE = 1, OPTION_TWO = 2, OPTION_THREE = 3 }; const optionArgs = joi.object({ option: joi.number().valid(...Object.values(Options).filter(o => typeof o === 'number')) }) type OptionSchema = joi.extractType<typeof optionArgs> // passes (expect to pass) const myObjOne: OptionSchema = { option: 1 }; // passes (expect to fail) const myObjTwo: OptionSchema = { option: 9 }; // fails (expect to fail) const myObjThree: OptionSchema = { option: 'help' };
Versions
"dependencies": { "@hapi/joi": "17.1.1", "joi-extract-type": "15.0.8" }
The text was updated successfully, but these errors were encountered:
Just occurred to me this is not necessarily enum specific and is more of a support of the valid() method...
valid()
Looks like it's mentioned here a while back 👀
#5 (comment)
Sorry, something went wrong.
No branches or pull requests
It would be great to see support of
enum
values through to extracted types.I've just tested out the following code with the
@latest
tag of@hapi/joi
&joi-extract-type
and it appears they aren't carried through.Are there any plans to support? Has it been looked at before?
Versions
The text was updated successfully, but these errors were encountered: