-
-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.4.4 The command in the template doesn't work.
What platform is your computer?
Darwin 24.5.0 arm64 arm
What steps can reproduce the bug?
https://elysiajs.com/patterns/error-handling.html#custom-validation-message
When not using the new? validationDetail function, the type is still inferred by eden as the standard validation error structure.
Using validationDetail
export const EmailAddress = t.String({
format: 'email',
error: validationDetail('Please enter a valid email address.'),
});{
"type": "validation",
"on": "body",
"value": {
"email": "not-an-email",
},
"property": "/email",
"message": "Please enter a valid email address.",
"summary": "Property 'email' should be email",
"found": {
"email": "not-an-email",
},
"expected": {
"type": "Could not create expected value",
"message": "String types with formats must specify a default value",
"error": {
"schema": {
"format": "email",
"type": "string"
}
}
},
"errors": [
{
"type": 50,
"schema": {
"format": "email",
"type": "string"
},
"path": "/email",
"email": "not-an-email",
"message": "Expected string to match 'email' format",
"errors": [],
"summary": "Property 'email' should be email"
}
]
}NOT using validationDetail
export const EmailAddress = t.String({
format: 'email',
error: 'Please enter a valid email address.',
});"Please enter a valid email address."What is the expected behavior?
Eden treaty error.value should be of type string.
What do you see instead?
Eden treaty error.value type:
(property) value: {
type: "validation";
on: string;
summary?: string;
message?: string;
found?: unknown;
property?: string;
expected?: string;
}
^ This should be of type string when NOT using validationDetail
Additional information
As a follow up to this, is there any movement towards standardizing and simplifying validation errors and custom error messages? The current response is enormous and difficult to work with.
Have you try removing the node_modules and bun.lockb and try again yet?
N/A
heiwen
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working