私はREST JSON APIで検証するためにLaravel 5.2を使用しています。Laravel 5.2 - APIによる検証
私はコントローラを拡張し、ValidatesRequests
形質を使用してUserController
を持っています。
サンプルコード:しかし
public function render($request, Exception $e)
{
return response()->json([
'responseCode' => 1,
'responseTxt' => $e->getMessage(),
], 400);
}
、responseTxt
の検証時には、常に次のとおりです:
Array
(
[responseCode] => 1
[responseTxt] => The given data failed to pass validation.
)
これは私のExceptions/Handler.php
で、私はこのコードを持っているので、例外がスローされます
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:4|max:72',
'identifier' => 'required|min:4|max:36',
'role' => 'required|integer|exists:role,id',
]);
私は過去にLaravel 4.2を使用しており、検証エラーを覚えています検証に失敗したことの詳細については、
どのフィールドが検証に失敗したのか、その理由を知るにはどうすればよいですか?