List of usage examples for org.springframework.validation FieldError getRejectedValue
@Nullable
public Object getRejectedValue()
From source file:org.springframework.data.rest.webmvc.support.RepositoryConstraintViolationExceptionMessage.java
/** * Creates a new {@link RepositoryConstraintViolationExceptionMessage} for the given * {@link RepositoryConstraintViolationException} and {@link MessageSourceAccessor}. * // ww w.j av a2 s . c o m * @param exception must not be {@literal null}. * @param accessor must not be {@literal null}. */ public RepositoryConstraintViolationExceptionMessage(RepositoryConstraintViolationException exception, MessageSourceAccessor accessor) { Assert.notNull(exception, "RepositoryConstraintViolationException must not be null!"); Assert.notNull(accessor, "MessageSourceAccessor must not be null!"); for (FieldError fieldError : exception.getErrors().getFieldErrors()) { this.errors.add(ValidationError.of(fieldError.getObjectName(), fieldError.getField(), fieldError.getRejectedValue(), accessor.getMessage(fieldError))); } }
From source file:org.springframework.validation.SimpleErrors.java
@Override public Object getFieldValue(String field) { FieldError fieldError = getFieldError(field); if (fieldError == null) { return null; } else {//from w w w . j av a 2s .c o m return fieldError.getRejectedValue(); } }
From source file:org.springframework.xd.dirt.server.container.ContainerServerApplication.java
private void handleFieldErrors(Exception e) { if (e.getCause() instanceof BindException) { BindException be = (BindException) e.getCause(); for (FieldError error : be.getFieldErrors()) { logger.error(String.format("the value '%s' is not allowed for property '%s'", error.getRejectedValue(), error.getField())); }/*from w w w . j a v a2 s.c om*/ } else { e.printStackTrace(); } System.exit(1); }