-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add support for transform types #127
Conversation
Could you adjust the versions in CI? |
Ah, sorry, didn't know that existed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if a TransformType is used with the stock validator compiler?
Hrmm, yeah, I guess that won't work. Honestly I've just always used these together. I guess that means that this would need two independent type providers, e.g. Regarding the tests, I'll try to track down which specific version had I'll close this for now and try to come up with something else. It'll probably be a few days before I can get back to it though. |
@ehaynes99, followed your setup as it is super handy for our scenario. But it seems the conversion works only for query, params and headers. Is there a way to decode the body also (I receive ids represented as strings and it's needed to be converted to Mongo ObjectIds)? |
@tothdanielax Hrmm, I'm not sure how that's possible. The test I added for The TypeBox author added a PR for this a while ago, but ended up closing it because of the version range issue. That's probably a better way forward because it handles the case @mcollina mentions as it precludes the combination of transform types without transforms in the validator compiler. Sorry, I've been pretty swamped, but I'll try to resurrect that one instead. I think the syntax can easily be adapted to have flags for the other two new options (though i guess that would prompt an even narrower version range, so we could add it separately). Using the same parameter names from ajv, that could look something like: const fastify = TypeBoxTransformProvider(Fastify(), {
removeAdditional: true,
useDefaults: true,
}) |
fixes #125
Checklist
npm run test
andnpm run benchmark
(tests pass, but nobenchmark
script exists)and the Code of conduct