use of org.springframework.validation.BindingResult in project entando-core by entando.
the class RestExceptionHandler method processValidationError.
@ExceptionHandler(value = ValidationGenericException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorRestResponse processValidationError(ValidationGenericException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
BindingResult result = ex.getBindingResult();
return processAllErrors(result);
}
use of org.springframework.validation.BindingResult in project entando-core by entando.
the class RestExceptionHandler method processValidationError.
@ExceptionHandler(value = ValidationUpdateSelfException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
@ResponseBody
public ErrorRestResponse processValidationError(ValidationUpdateSelfException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
BindingResult result = ex.getBindingResult();
return processAllErrors(result);
}
use of org.springframework.validation.BindingResult in project tutorials by eugenp.
the class ExceptionTranslator method processValidationError.
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorVM processValidationError(MethodArgumentNotValidException ex) {
BindingResult result = ex.getBindingResult();
List<FieldError> fieldErrors = result.getFieldErrors();
return processFieldErrors(fieldErrors);
}
use of org.springframework.validation.BindingResult in project tutorials by eugenp.
the class ExceptionTranslator method processValidationError.
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorVM processValidationError(MethodArgumentNotValidException ex) {
BindingResult result = ex.getBindingResult();
List<FieldError> fieldErrors = result.getFieldErrors();
return processFieldErrors(fieldErrors);
}
use of org.springframework.validation.BindingResult in project cetc by DiscoverForever.
the class ExceptionTranslator method handleMethodArgumentNotValid.
@Override
public ResponseEntity<Problem> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @Nonnull NativeWebRequest request) {
BindingResult result = ex.getBindingResult();
List<FieldErrorVM> fieldErrors = result.getFieldErrors().stream().map(f -> new FieldErrorVM(f.getObjectName(), f.getField(), f.getCode())).collect(Collectors.toList());
Problem problem = Problem.builder().withType(ErrorConstants.CONSTRAINT_VIOLATION_TYPE).withTitle("Method argument not valid").withStatus(defaultConstraintViolationStatus()).with("message", ErrorConstants.ERR_VALIDATION).with("fieldErrors", fieldErrors).build();
return create(ex, problem, request);
}
Aggregations