Example usage for org.apache.commons.validator.routines BigDecimalValidator isInRange

List of usage examples for org.apache.commons.validator.routines BigDecimalValidator isInRange

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines BigDecimalValidator isInRange.

Prototype

public boolean isInRange(BigDecimal value, double min, double max) 

Source Link

Document

Check if the value is within a specified range.

Usage

From source file:com.iana.boesc.utility.BOESCUtil.java

/**
 * Validates whether data provided is in percentage or not
 * //from w  w  w . j a va 2  s.c o  m
 * @param percentVal
 * @return
 */
public static boolean percentValidator(String percentVal) {
    BigDecimalValidator validator = PercentValidator.getInstance();
    boolean valid = false;
    BigDecimal Percent = validator.validate(percentVal, Locale.US);
    if (Percent == null) {
        valid = false;
    }
    // Check the percent is between 0% and 100%
    if (validator.isInRange(Percent, 0, 1)) {
        valid = true;
    } else {
        valid = false;
    }
    return valid;
}