-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
loopbackio/loopback-datasource-juggler
#45Description
@raymondfeng @Schoonology @bajtos
Currently we have poor support for responding with validation errors. Below is an overview of what we have and what I think we should move to. Any suggestions would be helpful before making any changes. This might require changes in the iOS SDK, strong-remoting, and the datasource juggler.
- Using a simple
Todomodel (ex 1). - Making an HTTP request to create a model (ex 2)
- Current response (ex 3)
- Potential / Improved response (ex 4)
- Status code 422
- Body should support multiple errors...
ex 1
app.model(
loopback
.memory()
.createModel('todo', {
task: 'string',
done: 'boolean',
owner: {type: 'string', required: true}
})
)ex 2
POST /todos HTTP/1.1
Content-Type: application/json
{
"task": "testing...",
"done": false
}ex 3
HTTP/1.1 400 Bad Requestex 4
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json
{
"errors": {
"owner": ["owner is required"]
}
}Metadata
Metadata
Assignees
Labels
No labels