How to remove slash '\' character out of error messages
Closed this issue · 4 comments
cuongsimplypost commented
Hi all,
I'm using joi to validate my apis request. All things is good except the error message return the field name with slash '' character.
{
"message": "validation error",
"error": {
"status": 400,
"statusText": "Bad Request",
"errors": [
{
"field": "email",
"location": "body",
"messages": [
"\"email\" must be a valid email"
],
"types": [
"string.email"
]
}
]
}
}
Do we have any option to remove it ?
Thanks,
colthreepv commented
\"
are necessary to escape "
double quotes in the JSON body.
What you ask is change the error message from "email" must be valid
to email must be valid
?
cuongsimplypost commented
Hi @colthreepv : I think "email must be a valid email" is better.
colthreepv commented
The message is directly from joi
, in this library there are no strings involved, It will simply forward joi error to expressjs.
You can still edit all the Joi configuration options, before creating a validation object for express-validation
cuongsimplypost commented
@colthreepv : Thanks for your clarification 👍