Example usage for org.springframework.validation Errors rejectValue

List of usage examples for org.springframework.validation Errors rejectValue

Introduction

In this page you can find the example usage for org.springframework.validation Errors rejectValue.

Prototype

void rejectValue(@Nullable String field, String errorCode, String defaultMessage);

Source Link

Document

Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description.

Usage

From source file:org.opensprout.osaf.util.ValidateUtils.java

public static void rejectIfConditionFalse(Boolean confition, Errors errors, String fieldName, String errorCode,
        String defaultMessage) {//www . ja v a2s.  c  om

    if (confition)
        errors.rejectValue(fieldName, errorCode, defaultMessage);
}

From source file:org.opensprout.osaf.util.ValidateUtils.java

public static void rejectIfNullOrZero(Integer value, Errors errors, String fieldName, String errorCode,
        String defaultMessage) {/*from   w w  w  .  j a  v  a  2 s.c o m*/

    if (value == null || value == 0)
        errors.rejectValue(fieldName, errorCode, defaultMessage);

}

From source file:com.wisemapping.validator.ValidatorUtils.java

public static void rejectIfExceeded(org.springframework.validation.Errors errors, java.lang.String title,
        java.lang.String message, String value, int limit) {
    if (value != null && value.length() > limit) {
        errors.rejectValue(title, "field.max.length", message);
    }/*  w w w  .  j a  va 2  s. co  m*/
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfNull(Errors errors, Object data, String field, String errorCode, String errorMsg) {
    if (data == null) {
        errors.rejectValue(field, errorCode, errorMsg);
    }//from   w  ww .j  av a  2s.  c o m
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfNullOrEmpty(Errors errors, String data, String field, String errorCode,
        String errorMsg) {//w  ww .ja v  a2 s  .c o m
    if (data == null || StringUtils.isBlank(data)) {
        errors.rejectValue(field, errorCode, errorMsg);
    }
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfInvalidDate(Errors errors, Date data, String field, String errorCode,
        String errorMsg) {/* ww w  . j  ava  2 s  .  c  o  m*/
    Date date = new Date();
    if (data.compareTo(date) <= 0) {
        errors.rejectValue(field, errorCode, errorMsg);
    }
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfInvalidType(Errors errors, String data, String field, String errorCode,
        String errorMsg, Map<String, String> typeParam) {
    if (!typeParam.containsKey(data)) {
        errors.rejectValue(field, errorCode, errorMsg);
    }//w  w w.ja v  a2  s. com
}

From source file:org.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfInvalid(Errors errors, Double data, String field, String errorCode, String errorMsg,
        Map<Double, String> ratingScore) {
    if (!ratingScore.containsKey(data)) {
        errors.rejectValue(field, errorCode, errorMsg);
    }//from  www .  j a  va 2s  . c  o m
}

From source file:org.kuali.mobility.askiu.controllers.AskIUController.java

@RequestMapping(method = RequestMethod.POST)
public String submitFeedback(Model uiModel, @ModelAttribute("askiu") AskIU ask, BindingResult result) {
    if (isValidQuery(ask, result)) {
        if (askiuService.postQuery(ask)) {
            return "askiu/confirmation";
        } else {// w  w w . ja v a 2 s  .c  om
            Errors errors = ((Errors) result);
            errors.rejectValue("message", "",
                    "There was an error sending your query.  Please try again later.");
            return "askiu/form";
        }
    } else {
        return "askiu/form";
    }
}

From source file:org.hydroponics.web.validator.GrowValidator.java

public void validate(GrowEditBean book, Errors errors) {
    String name = book.getName();
    if (!StringUtils.hasLength(name)) {
        errors.rejectValue("name", "required", "required");
    }/*w  w w.j  av a2s .c o  m*/
}