FriendsOfSymfony/FOSRestBundle — pull request #544 by tonivdv (2013-09-01 17:21:02+00:00)
Title: POC to return a form with validation errors in the same way as Exceptions...

I started this PR after asking (https://github.com/FriendsOfSymfony/FOSRestBundle/issues/541) what the best way was to handle api responses with non-valid forms.

Personally I don't like how it returned out of the box:

```javascript
{
"children": {
"username": {
"errors": [
"This value should not be blank."
]
}
}
}
```
I wanted something that could be incorporated into the error messages you get when calling

```php
throw new HttpException(400, "New comment is not valid.");
```
```javascript
{
"status": "error",
"status_code": 400,
"status_text": "Bad Request",
"current_content": "",
"message": "New comment is not valid."
}
```
I changed a couple of files and was able to get following results if a non valid form is returned:

```javascript
{
"status": "error",
"status_code": 400,
"status_text": "Bad Request",
"current_content": "",
"message": "Validation Failed";
"errors": {
"children": {
"username": {
"errors": [
"This value should not be blank."
]
}
}
}
}
```

Let me know your thoughts about this.

Cheers