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

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

Introduction

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

Prototype

public boolean isValid(String value) 

Source Link

Document

Validate using the default Locale.

Usage

From source file:org.mule.modules.validation.ValidationModule.java

/**
 * If the specified <code>percentage</code> is not a valid one throw an exception.
 * <p/>//from   ww  w .  ja  va2s.c om
 * {@sample.xml ../../../doc/mule-module-validation.xml.sample validation:validate-percentage}
 *
 * @param percentage               Percentage to validate
 * @param customExceptionClassName Class name of the exception to throw
 * @throws Exception if not valid
 */
@Processor
public void validatePercentage(String percentage,
        @Optional @Default("org.mule.modules.validation.InvalidException") String customExceptionClassName)
        throws Exception {
    BigDecimalValidator validator = PercentValidator.getInstance();

    if (!validator.isValid(percentage)) {
        throw buildException(customExceptionClassName);
    }
}