Skip to content

Commit

Permalink
Merge pull request #12 from syamsoul/bugfix/validation
Browse files Browse the repository at this point in the history
should return default laravel validation error response
  • Loading branch information
syamsoul authored Jun 26, 2024
2 parents 654afc9 + 06f5909 commit 4aabf19
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/Handler/QueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,6 @@ private function validateRequest(array $rules, array $error_messages = [])

$validator = Validator::make($request->all(), $rules, $error_messages);

if ($validator->fails()) {
if ($request->expectsJson()) {
$errors = $validator->errors();

abort(response()->json([
'message' => $errors->first(),
'errors' => $errors->toArray(),
], 403));
} else {
abort(422, $validator->messages()->first());
}
}
$validator->validate();
}
}

0 comments on commit 4aabf19

Please sign in to comment.