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);

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.logger.event.web.utils.ServerValidationUtils.java

public static void rejectIfAnyException(Errors errors, String errorCode, Exception exception) {
    errors.rejectValue(errorCode, exception.toString());
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.AddressValidator.java

protected static void validateFieldNotNull(final String addressField, final AddressField fieldType,
        final Errors errors) {
    if (addressField == null) {
        errors.rejectValue(fieldType.getFieldKey(), fieldType.getErrorKey());
    }/*from   w  w w .  j  av a 2s.  c o m*/
}

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

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

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

public static void rejectIfNullOrEmpty(Errors errors, Set<?> data, String field, String errorMsg) {
    if (data == null || data.size() == 0) {
        errors.rejectValue(field, errorMsg);
    }//from  w ww  . j ava2s  . c  o  m
}

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

public static void rejectIfNullOrEmpty(Errors errors, String data, String field, String errorMsg) {
    if (data == null || StringUtils.isBlank(data)) {
        errors.rejectValue(field, errorMsg);
    }/*  www  . j  av  a2  s .  com*/
}

From source file:org.sloth.util.ValidationUtils.java

/**
 * // www  . java2s  . com
 * @param errors
 *            the {@link Errors} instance that should store the errors (must
 *            not be <code>null</code>)
 * @param field
 *            the field name to check
 * @param errorCode
 *            the error code, interpretable as message key
 * @return {@code true} if field is not {@code null}, otherwise {@code
 *         false}
 */
public static boolean rejectIfNull(Errors errors, String field, String errorCode) {
    if (notNull(errors.getFieldValue(field))) {
        return true;
    } else {
        errors.rejectValue(field, errorCode);
        return false;
    }
}

From source file:org.ahp.commons.validator.AbstractValidator.java

@SafeVarargs
public static void populateErrors(Errors pErrors, String pPathName, Set<String>... pErrorKeySet) {
    for (Set<String> lErrorKeySet : pErrorKeySet) {
        for (String lErrorKey : lErrorKeySet) {
            pErrors.rejectValue(pPathName, lErrorKey);
        }/*  ww  w. ja  va 2  s . com*/
    }
}

From source file:org.sloth.util.ValidationUtils.java

/**
 * //from w w  w  .ja v  a 2s .com
 * @param errors
 *            the {@link Errors} instance that should store the errors (must
 *            not be <code>null</code>)
 * @param field
 *            the field name to check
 * @param errorCode
 *            the error code, interpretable as message key
 * @param maxLength
 *            the maximum length of {@code field}
 */
public static void rejectIfTooLong(Errors errors, String field, String errorCode, int maxLength) {
    Object o = errors.getFieldValue(field);
    if (notNull(o)) {
        if (((String) o).length() > maxLength) {
            errors.rejectValue(field, errorCode);
        }
    }
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.AddressValidator.java

protected static void validateStringField(final String addressField, final AddressField fieldType,
        final int maxFieldLength, final Errors errors) {
    if (addressField == null || StringUtils.isEmpty(addressField)
            || (StringUtils.length(addressField) > maxFieldLength)) {
        errors.rejectValue(fieldType.getFieldKey(), fieldType.getErrorKey());
    }//from  w  w w  .  j a v  a  2  s .  c o m
}

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

static void validateEmailAddress(final String email, final Errors errors) {
    if (email == null || email.trim().length() == 0) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", Messages.FIELD_REQUIRED);
    } else {// ww w .j  a  va  2 s  .co m
        boolean isValid = Utils.isValidateEmailAddress(email);
        if (!isValid) {
            errors.rejectValue("email", Messages.NO_VALID_EMAIL_ADDRESS);
        }
    }
}