/** * Build a validator that checks that given value is greater than or equal to <code>min</code> value, and uses * {@link ValidationMessage#MAX} as validation error message. * <p> * Null values are ignored. * </p> * <p> * Supported data types: {@link CharSequence}, {@link Number}, {@link Collection}, {@link Map} and arrays. * </p> * <ul> * <li>String: the string length is checked against given min value (converted to a long)</li> * <li>Integer numbers: the number value is checked against given min value (converted to a long)</li> * <li>Decimal numbers: the number value is checked against given min value</li> * <li>Collections, Maps and arrays: size/length is checked against given min value</li> * </ul> * <p> * If the data type only supports integer max value validation (for example, a String length), the given * <code>max</code> value is treated as an integer value, casting it to an <code>int</code> or a <code>long</code>. * </p> * @param <T> Validator type * @param min Min value * @return Validator * @throws UnsupportedValidationTypeException If value to validate is of an unsupported data type */ static <T> Validator<T> min(double min) { return min(min, ValidationMessage.MIN); }
/** * Build a validator that checks that given value is greater than or equal to <code>min</code> value, and uses given * {@link Localizable} <code>message</code> as validation error message. * <p> * Null values are ignored. * </p> * <p> * Supported data types: {@link CharSequence}, {@link Number}, {@link Collection}, {@link Map} and arrays. * </p> * <ul> * <li>String: the string length is checked against given min value (converted to a long)</li> * <li>Integer numbers: the number value is checked against given min value (converted to a long)</li> * <li>Decimal numbers: the number value is checked against given min value</li> * <li>Collections, Maps and arrays: size/length is checked against given min value</li> * </ul> * <p> * If the data type only supports integer max value validation (for example, a String length), the given * <code>max</code> value is treated as an integer value, casting it to an <code>int</code> or a <code>long</code>. * </p> * @param <T> Validator type * @param min Min value * @param message Validation error message * @return Validator * @throws UnsupportedValidationTypeException If value to validate is of an unsupported data type */ static <T> Validator<T> min(double min, Localizable message) { ObjectUtils.argumentNotNull(message, "Validation error message must be not null"); return min(min, message.getMessage(), message.getMessageCode()); }
property.validator(Validator.min(Long.valueOf(a.value()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MIN))); LOGGER.debug( }); property.getAnnotation(DecimalMin.class).ifPresent(a -> { property.validator(Validator.min(new BigDecimal(a.value()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MIN))); LOGGER.debug(() -> "BeanPropertyBeanValidationPostProcessor: added validator to property [" property.validator(Validator.min(Integer.valueOf(a.min()).doubleValue(), getValidationMessage(property, a.message(), Validator.ValidationMessage.MIN))); property.validator(Validator.max(Integer.valueOf(a.max()).doubleValue(),