Skip to content

Instantly share code, notes, and snippets.

Created Nov 26, 2015
What would you like to do?
public ValidationResponse createValidationResponse(BindingResult result, boolean translate) {
ValidationResponse response = new ValidationResponse();
if(!result.hasErrors()) {
return response;
Locale locale = LocaleContextHolder.getLocale();
for (FieldError error : result.getFieldErrors()) {
String message = translate ? messageSource.getMessage(error, locale) : error.getCode();
response.addError(error.getField(), message);
return response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment