Package org.springframework.validation

Examples of org.springframework.validation.FieldError


                            break;
                        }
                    }
                }
                Assert.isTrue(paramName != null);
                FieldError fieldError = new FieldError(//
                        "method", // 该出错字段所在的对象的名字;对于这类异常我们统一规定名字为method
                        paramName, // 出错的字段的名字;取其参数名
                        inv.getParameter(paramName), // 被拒绝的值
                        true,//whether this error represents a binding failure (like a type mismatch); else, it is a validation failure
                        new String[] { e.getErrorCode() },// "typeMismatch"
View Full Code Here


    if (finding != null && (finding.getLongDescription() == null ||
        finding.getLongDescription().trim().isEmpty())) {
      result.rejectValue("longDescription", "errors.required", new String [] { "Description" }, null);
    }

    FieldError originalError = result.getFieldError("dataFlowElements[0].lineNumber");
    if (originalError != null && originalError.getDefaultMessage()
        .startsWith("Failed to convert property value of type " +
            "'java.lang.String' to required type 'int'")) {
      result.rejectValue("dataFlowElements", "errors.invalid", new String [] { "Line number" }, null);
    }
View Full Code Here

                            break;
                        }
                    }
                }
                Assert.isTrue(paramName != null);
                FieldError fieldError = new FieldError(//
                        "method", // 该出错字段所在的对象的名字;对于这类异常我们统一规定名字为method
                        paramName, // 出错的字段的名字;取其参数名
                        inv.getParameter(paramName), // 被拒绝的值
                        true,//whether this error represents a binding failure (like a type mismatch); else, it is a validation failure
                        new String[] { e.getErrorCode() },// "typeMismatch"
View Full Code Here

    User existed = null;
    if (!result.hasFieldErrors("signInName")) {
      existed = userPepository.getByEmail(signInCredentialVo
          .getSignInName());
      if (existed == null) {
        result.addError(new FieldError("signInCredentialVo",
            "signInName", "注册邮箱不存在"));
      } else {
        if (!signInCredentialVo.getSignInPassword().equals(
            existed.getPassword())) {
          result.addError(new FieldError("signInCredentialVo",
              "signInPassword", "密码不正确"));
        }
        if(existed.getStatus() == UserStatus.INVALID){
          result.addError(new FieldError("signInCredentialVo",
              "signInName", "账号暂时不能登陆"));
        }
      }
    }
    if (result.hasErrors()) {
View Full Code Here

    User existed = null;
    if (!result.hasFieldErrors("signInName")) {
      existed = userPepository.getByEmail(signInCredentialVo
          .getSignInName());
      if (existed == null) {
        result.addError(new FieldError("signInCredentialVo",
            "signInName", "注册邮箱不存在"));
      } else {
        if (!signInCredentialVo.getSignInPassword().equals(
            existed.getPassword())) {
          result.addError(new FieldError("signInCredentialVo",
              "signInPassword", "密码不正确"));
        }
        if(existed.getStatus() == UserStatus.INVALID){
          result.addError(new FieldError("signInCredentialVo",
              "signInName", "账号暂时不能登陆"));
        }
      }
    }
View Full Code Here

      Model model, HttpSession session){
    User existed = null;
    if(!result.hasFieldErrors("email")){
      existed = userRepository.getByEmail(signUpUserVo.getEmail());
      if(existed !=null){
        result.addError(new FieldError("signUpUserVo", "email", "这个邮箱太受欢迎了,换一个吧"));
      }
    }
    if(!result.hasFieldErrors("name")){
      existed = userRepository.getByName(signUpUserVo.getName());
      if(existed != null){
        result.addError(new FieldError("signUpUserVo", "name", "这个昵称太抢手了,换一个吧"));
      }
    }
    if(result.hasErrors()){
      return "sign.up";
    }
View Full Code Here

    String name = formBean.getName();
    User signInUser = sessionUtil.getSignInUser(session);
    if (!signInUser.getName().equals(name)) {
      User user = userRepository.getByName(name);
      if (user != null) {
        result.addError(new FieldError("formBean", "name",
            "这个昵称太抢手了,换一个吧"));
      }
    }
    if (result.hasErrors()) {
      return ValidationEngineError.normalize(ValidationEngineError
View Full Code Here

    if (signInUser == null) {
      return new AjaxResult(AjaxResultCode.NEED_SIGNIN);
    }
    if (formBean.getOldPwd() != null
        && !formBean.getOldPwd().equals(signInUser.getPassword())) {
      result.addError(new FieldError("formBean", "oldPwd", "密码不正确"));
    }
    if (result.hasErrors()) {
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
View Full Code Here

  Object[] validateChangePwd(@Valid UserPwdChangeFormBean formBean,
      BindingResult result, ModelAndView mav, HttpSession session) {
    User signInUser = sessionUtil.getSignInUser(session);
    if (formBean.getOldPwd() != null
        && !formBean.getOldPwd().equals(signInUser.getPassword())) {
      result.addError(new FieldError("formBean", "oldPwd", "密码不正确"));
    }
    if (result.hasErrors()) {
      return ValidationEngineError.normalize(ValidationEngineError
          .from(result));
    } else {
View Full Code Here

    Account account = new Account("123456001", "Keith and Keri Donald");
    account.setEntityId(0L);
    Errors errors = new BeanPropertyBindingResult(account, "account");
    validator.validate(account, errors);
    assertEquals("One error should be registered", 1, errors.getErrorCount());
    FieldError error = errors.getFieldError("number");
    assertNotNull(error);
    assertEquals("account.number.inuse", error.getCode());
  }
View Full Code Here

TOP

Related Classes of org.springframework.validation.FieldError

Copyright © 2018 www.massapicom. 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.