strongloop/loopback-datasource-juggler — pull request #45 by bajtos (2013-11-25 16:31:57+00:00)
Title: Improve properties of ValidationError

Improve properties of ValidationError:
- change `statusCode` from 400 to 422
- nest `context` and `codes` inside `details`
- add `details.messages`
- reword the main error message

Remove the call to Error's constructor from ValidationError constructor, because it's a no-op - Error's constructor creates a new instance when called via `.call()`.

/to: @raymondfeng or @ritch: please review
/cc: @Schoonology

Close strongloop/loopback#21

**A sample response**

```json
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The object is not valid, see this.details for more info.",
"statusCode": 422,
"details": {
"context": "todo",
"codes": {
"owner": [
"presence"
]
},
"messages": {
"owner": [
"can't be blank"
]
}
},
"stack": "ValidationError: The object is not valid, see this.details for more info.\n at [etc.]"
}
}
```