-
Notifications
You must be signed in to change notification settings - Fork 24
Support array objects as data #64
Comments
I have a fix for this in #65. Your proposed solution does make sense. The main reason to have an |
I think the additional parameter should work, it's better than not being able to pass the |
Can you show an example how you would like to call it? |
Example: const errors = [
{
"keyword": "required",
"dataPath": "",
"schemaPath": "#/required",
"params": {
"missingProperty": "customerId"
},
"message": "should have required property 'customerId'"
}
];
throw new errors.BadRequest("Input validation failed", null, errors); And in the code, if |
Should I work on a pull request? |
Sorry late to the game here but any reason data has to be an array or was the issue just that you want const errors = [
{
"keyword": "required",
"dataPath": "",
"schemaPath": "#/required",
"params": {
"missingProperty": "customerId"
},
"message": "should have required property 'customerId'"
}
];
throw new errors.BadRequest('Input validation failed', { errors }); Which should result in this: {
"name": "BadRequest",
"message": "JSON-Schema validation failed",
"code": 400,
"className": "bad-request",
"data": {},
"errors": [
{
"keyword": "required",
"dataPath": "",
"schemaPath": "#/required",
"params": {
"missingProperty": "customerId"
},
"message": "should have required property 'customerId'"
}
]
} |
Steps to reproduce
Expected behavior
Response:
Actual behavior
Response:
More
The problem is here:
https://github.com/feathersjs/feathers-errors/blob/master/src/index.js#L36
Proposed solution
If we could make the 'errors' property of the data object a parameter instead, we won't have the problem of messing with immutable data and it will also enable us to pass an error object, alongside with an array object as data.
The text was updated successfully, but these errors were encountered: