Example usage for org.springframework.validation Errors getFieldValue

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

Introduction

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

Prototype

@Nullable
Object getFieldValue(String field);

Source Link

Document

Return the current value of the given field, either the current bean property value or a rejected update from the last binding.

Usage

From source file:org.tsm.concharto.web.util.ValidationHelper.java

public static void rejectIfTooLong(Errors errors, String field, int maxLength, String errorCode) {
    Object value = errors.getFieldValue(field);
    if (value != null) {
        rejectIfTooLong(errors, field, maxLength, errorCode,
                new Object[] { maxLength, value.toString().length() }, null);
    }/*from  ww  w  . ja  v a2 s  .c  om*/
}

From source file:de.ingrid.interfaces.csw.admin.validation.AbstractValidator.java

public static final Object get(final Errors errors, final String field) {
    return errors.getFieldValue(field);
}

From source file:de.ingrid.interfaces.csw.admin.validation.AbstractValidator.java

public static final Float getFloat(final Errors errors, final String field) {
    return (Float) errors.getFieldValue(field);
}

From source file:de.ingrid.interfaces.csw.admin.validation.AbstractValidator.java

public static final String getString(final Errors errors, final String field) {
    return (String) errors.getFieldValue(field);
}

From source file:de.ingrid.interfaces.csw.admin.validation.AbstractValidator.java

public static final Boolean getBoolean(final Errors errors, final String field) {
    return (Boolean) errors.getFieldValue(field);
}

From source file:de.ingrid.interfaces.csw.admin.validation.AbstractValidator.java

public static final Integer getInteger(final Errors errors, final String field) {
    return (Integer) errors.getFieldValue(field);
}

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

/**
 * /* w  w w  .j  ava 2s.c  om*/
 * @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.tsm.concharto.web.util.ValidationHelper.java

public static void rejectIfTooLong(Errors errors, String field, int maxLength, String errorCode,
        Object[] errorArgs, String defaultMessage) {
    Object value = errors.getFieldValue(field);

    if (value.toString().length() > maxLength) {
        errors.rejectValue(field, errorCode, errorArgs, defaultMessage);
    }/*from  w w  w  .  j a  v a 2s  .c o  m*/

}

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

/**
 * //from   w  w w. ja  va2s .  c o m
 * @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:biz.deinum.multitenant.validation.AbstractSimpleClassMappingValidator.java

protected Object getValue(final Errors errors) {
    return errors.getFieldValue(this.field);
}