Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Last active April 28, 2020 02:34
Show Gist options
  • Save CheolhoJeon/a8fd96308077e38d38535fd3dac81785 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/a8fd96308077e38d38535fd3dac81785 to your computer and use it in GitHub Desktop.
@PostMapping("/api/members")
public void newMember(@RequestBody @Valid RegisterRequest regReq, Errors errors) throws IOException {
if (errors.hasErrors()) {
String errorCodes = errors
.getAllErrors()
.stream()
.map(error -> error.getCodes()[0])
.collect(Collectors.joining(","));
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body(new ErrorResponse("errorCodes = " + errorCodes));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment