Open wavpro opened 1 month ago
1.0.22
Microsoft Windows NT 10.0.19045.0 x64
import { Elysia, t } from 'elysia' new Elysia() .guard( { params: t.Object({ id: t.Numeric(), }), query: t.Object({ size: t.Union([ t.Literal(512), t.Literal(128), t.Literal(64) ]) }) }, (app) => app .get('/tracks/:id/cover', async ({ params: { id }, query: { size } }) => { return "Hello world!"; }) ) .listen(3000);
This applies to both queries and params, showcased as query in the code above.
It should find the type that the t.Literal is, and cast the param/query to that before trying to compare to it.
t.Literal
I get this error when trying to access the page:
{ "type": "validation", "on": "query", "property": "/size", "message": "Expected union value", "expected": { "size": 512 }, "found": { "size": "128" }, "errors": [ { "type": 62, "schema": { "anyOf": [ { "const": 512, "type": "number" }, { "const": 128, "type": "number" }, { "const": 64, "type": "number" } ] }, "path": "/size", "value": "128", "message": "Expected union value" } ] }
No response
What version of Elysia.JS is running?
1.0.22
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What steps can reproduce the bug?
This applies to both queries and params, showcased as query in the code above.
What is the expected behavior?
It should find the type that the
t.Literal
is, and cast the param/query to that before trying to compare to it.What do you see instead?
I get this error when trying to access the page:
Additional information
No response