All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal.DecimalMinValidatorForCharSequence Maven / Gradle / Ivy

There is a newer version: 8.0.1.Final
Show newest version
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */
package org.hibernate.validator.internal.constraintvalidators.bv.number.bound.decimal;

import java.math.BigDecimal;

/**
 * Check that the character sequence (e.g. string) being validated represents a number, and has a value greater than or
 * equal to the minimum value specified.
 *
 * @author Hardy Ferentschik
 * @author Guillaume Smet
 */
public class DecimalMinValidatorForCharSequence extends AbstractDecimalMinValidator {

	@Override
	protected int compare(CharSequence number) {
		try {
			return DecimalNumberComparatorHelper.compare( new BigDecimal( number.toString() ), minValue );
		}
		catch (NumberFormatException nfe) {
			return -1;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy