loopback
loopback copied to clipboard
Question : how to change error message?
from
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The `User` instance is not valid. Details: `password` can't be blank.",
"statusCode": 422,
"details": {
"context": "User",
"codes": {
"password": [
"presence"
]
},
"messages": {
"password": [
"can't be blank"
]
}
}
}
}
to
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "Password can't be blank.",
"statusCode": 422,
"details": {
"context": "User",
"codes": {
"password": [
"presence"
]
},
"messages": {
"password": [
"Password can't be blank"
]
}
}
}
}
Have you found the solution? I am looking exactly for the same thing.
I am also looking for the same thing.
+1
In the .js files (not .json) of the models, have if conditions, and in the else part:
var error = new Error('Your custom error message.');
error.status = 403; //your desired code
next(error);
is this the only solution? hard code it? Cant believe loopback is so complex and the most important things are left out to be changed manually...insane..