Open hyoretsu opened 1 month ago
1.1.13
Microsoft Windows NT 10.0.22631.0 x64
Use this validation in a route
body: t.Union([ t.Object({ bookmarked: t.Optional(t.Boolean()), link: t.Optional(t.String({ format: "uri" })), timeSpent: t.Optional(t.String()), when: t.Optional(t.Date()), }), t.Object({ bookmarked: t.Optional(t.Boolean()), mediaId: t.String(), number: t.Integer(), timeSpent: t.Optional(t.String()), when: t.Optional(t.Date()), }), t.Object({ bookmarked: t.Optional(t.Boolean()), mediaId: t.Optional(t.String()), timeSpent: t.Optional(t.String()), when: t.Optional(t.Date()), }), ])
And provide this body:
{ "mediaId": "610132145125381", "number": 1127, "timeSpent": "PT4M35S", "when":"2024-09-20T22:05:00.000-03:00" }
This shouldn't be an edge case and it should recognize the body as the second type.
It recognizes the body as the first type and simply deletes mediaId and number from the body. They exist in ctx.body during onTransform;
mediaId
number
ctx.body
onTransform
No response
node_modules
bun.lockb
If I add { additionalProperties: false }, to the first field it works.
{ additionalProperties: false },
Can u try it with plain typebox?
What version of Elysia is running?
1.1.13
What platform is your computer?
Microsoft Windows NT 10.0.22631.0 x64
What steps can reproduce the bug?
Use this validation in a route
And provide this body:
What is the expected behavior?
This shouldn't be an edge case and it should recognize the body as the second type.
What do you see instead?
It recognizes the body as the first type and simply deletes
mediaId
andnumber
from the body. They exist inctx.body
duringonTransform
;Additional information
No response
Have you try removing the
node_modules
andbun.lockb
and try again yet?No response