-
-
Notifications
You must be signed in to change notification settings - Fork 396
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.2.24
What platform is your computer?
Microsoft Windows NT 10.0.22631.0 x64
What steps can reproduce the bug?
import { Elysia, t } from "elysia";
const testModel = new Elysia().model({
sign: t.Object({
username: t.String(),
age: t.Number(),
}),
});
const app = new Elysia()
.use(testModel)
// to check error in console (not necessarily)
.onError(({ error }) => {
console.log(error);
})
.post("/", ({ body }) => body, {
body: "sign",
})
.listen(3000);
console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
);What is the expected behavior?
error: {
"type": "validation",
"on": "body",
"summary": "Property 'age' is missing",
"property": "/age",
"message": "Expected required property",
"expected": {
"username": "",
"age": 0
},
"found": {
"username": "test"
},
"errors": [
{
"type": 45,
"schema": {
"type": "number"
},
"path": "/age",
"message": "Expected required property",
"errors": [],
"summary": "Property 'age' is missing"
},
{
"summary": "Expected number",
"type": 41,
"schema": {
"type": "number"
},
"path": "/age",
"message": "Expected number",
"errors": []
}
]
}
code: "VALIDATION"
at new ValidationError (REPLACED\node_modules\elysia\src\error.ts:264:3)
Response code: 422
What do you see instead?
27 | if(value.length===1)c.body[key]=value[0]
28 | else c.body[key]=value}break
29 | }
30 | delete c.contentType
31 | isParsing=false
32 | if(validator.body.Check(c.body)===false){if(typeof c.body==='object')c.body=Object.assign(undefined,c.body)
^
TypeError: Object.assign requires that input parameter not be null or undefined
Response code: 500
Additional information
Request body: { "username": "test" }
Request type: JSON
Runtime: Bun 1.2.4
Elysia version: 1.2.7 - 1.2.24 (1.2.6 and below are working as expected)
Have you try removing the node_modules and bun.lockb and try again yet?
yes
caturbgsga1az, dengyong-ola and caturbgs
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working