Api: FormRequest Validation - does not describe which fields failed validation

Created on 11 Dec 2017  路  6Comments  路  Source: dingo/api

| Q | A
| ----------------- | ---
| Bug? | yes
| New Feature? | no
| Framework | Larave
| Framework version | 5.5.*
| Package version | 2.0.0-alpha1
| PHP version | 7.1.10

Actual Behaviour

When using FormRequest to validate input given by client, and validation fails, it simply returns:

"message": "The given data was invalid.",

Along with status_code 500 + debug trace.

Expected Behaviour

I would expect it to give some more clues as to which validations that failed, and why.

Most helpful comment

1519

All 6 comments

Solution, in your FormRequest use

use Dingo\Api\Http\FormRequest;

Instead of

use Illuminate\Foundation\Http\FormRequest;

Sitting in the same boat, tried to do abstract class Form extends \Dingo\ApiHttpFormRequest, what error should be thrown?

Tried: $this->throwValidationException(request(), $validator) and: $this->failedValidation($validator)

But the status code is still 500

Indeed this should most definitely not be a 500

1519

Closing, PR was merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nghiepit picture nghiepit  路  4Comments

sukh-gill picture sukh-gill  路  3Comments

pongz79 picture pongz79  路  4Comments

MicroDroid picture MicroDroid  路  3Comments

BartHuis picture BartHuis  路  3Comments