Package org.springframework.validation

Examples of org.springframework.validation.MapBindingResult.addError()


    if (copy.size() > 0) {
      // We're just interested in a container for errors
      BindingResult bindingResult = new MapBindingResult(new HashMap<String, Object>(), "flattened");
      for (String pty : copy.keySet()) {
        bindingResult.addError(new FieldError("flattened", pty, String.format(
            "option named '%s' is not supported", pty)));
      }
      throw new BindException(bindingResult);
    }
View Full Code Here


  @Override
  public ModuleOptions interpolate(final Map<String, String> raw) throws BindException {
    MapBindingResult bindingResult = new MapBindingResult(new HashMap<String, String>(), "options");
    for (String provided : raw.keySet()) {
      if (!options.containsKey(provided)) {
        bindingResult.addError(new FieldError("options", provided, String.format(
            "Module option '%s' does not exist", provided)));
      }
    }

    if (bindingResult.hasErrors()) {
View Full Code Here

  @Test
  public void extractBindingResultErrors() throws Exception {
    BindingResult bindingResult = new MapBindingResult(Collections.singletonMap("a",
        "b"), "objectName");
    bindingResult.addError(new ObjectError("c", "d"));
    BindException ex = new BindException(bindingResult);
    this.request.setAttribute("javax.servlet.error.exception", ex);
    Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(
        this.requestAttributes, false);
    assertThat(attributes.get("message"), equalTo((Object) ("Validation failed for "
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.