public class

ValidationModule

extends Object
java.lang.Object
   ↳ org.mule.modules.validation.ValidationModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A common issue when receiving data either electronically or from user input is verifying the integrity of the data. This work is repetitive and becomes even more complicated when different sets of validation rules need to be applied to the same set of data based on locale. Error messages may also vary by locale. This module addresses some of these issues to speed development and maintenance of validation rules.

Summary

Public Constructors
ValidationModule()
Public Methods
void validateCreditCardNumber(String creditCardNumber, List<CreditCardType> creditCardTypes, String exceptionClassName)
If if the specified creditCardNumber is not a valid credit card number throw an exception.
void validateDate(String date, Locale locale, String pattern, String exceptionClassName)
If the specified date is not a valid one throw an exception.
void validateDomain(String domain, String exceptionClassName)
If the specified domain does not parses as a valid domain name with a recognized top-level domain then throw an exception.
void validateDouble(String value, Locale locale, String pattern, Double minValue, Double maxValue, String exceptionClassName)
If the specified value is not a valid Double throw an exception.
void validateEmail(String emailAddress, String exceptionClassName)
If the specified emailAddress is not a valid one throw an exception.
void validateFloat(String value, Locale locale, String pattern, Float minValue, Float maxValue, String exceptionClassName)
If the specified value is not a valid Float throw an exception.
void validateISBN10(String isbnCode, String exceptionClassName)
If the specified isbnCode is not a valid one throw an exception.
void validateISBN13(String isbnCode, String exceptionClassName)
If the specified isbnCode is not a valid one throw an exception.
void validateInteger(String value, Locale locale, String pattern, Integer minValue, Integer maxValue, String exceptionClassName)
If the specified value is not a valid Integer throw an exception.
void validateIpAddress(String ipAddress, String exceptionClassName)
If the specified ipAddress is not a valid one throw an exception.
void validateLong(String value, Locale locale, String pattern, Long minValue, Long maxValue, String exceptionClassName)
If the specified value is not a valid Long throw an exception.
void validateNotEmpty(Object object, String exceptionClassName)
If the specified object is empty or null throw an exception.
void validatePercentage(String percentage, String exceptionClassName)
If the specified percentage is not a valid one throw an exception.
void validateShort(String value, Locale locale, String pattern, Short minValue, Short maxValue, String exceptionClassName)
If the specified value is not a valid Short throw an exception.
void validateTime(String time, Locale locale, String pattern, String exceptionClassName)
If the specified time is not a valid one throw an exception.
void validateTopLevelDomain(String topLevelDomain, String exceptionClassName)
If if the specified topLevelDomain does not matches any IANA-defined top-level domain throw an exception.
void validateTopLevelDomainCountry(String countryCode, String exceptionClassName)
If if the specified countryCode does not matches any IANA-defined top-level domain throw an exception.
void validateUrl(String url, boolean allowTwoSlashes, boolean allowAllSchemes, boolean allowLocalURLs, boolean noFragments, String exceptionClassName)
If the specified url is not a valid one throw an exception.
void validateUsingRegex(String value, List<String> regexs, boolean caseSensitive, String exceptionClassName)
If the specified value does not match any of the regexs then throw an exception.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ValidationModule ()

Public Methods

public void validateCreditCardNumber (String creditCardNumber, List<CreditCardType> creditCardTypes, String exceptionClassName)

If if the specified creditCardNumber is not a valid credit card number throw an exception.

Parameters
creditCardNumber Credit card number to validate
creditCardTypes Credit card types to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateDate (String date, Locale locale, String pattern, String exceptionClassName)

If the specified date is not a valid one throw an exception.

Parameters
date Date to validate
locale The locale to use for the format
pattern The pattern used to format the value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateDomain (String domain, String exceptionClassName)

If the specified domain does not parses as a valid domain name with a recognized top-level domain then throw an exception.

Parameters
domain Domain name to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateDouble (String value, Locale locale, String pattern, Double minValue, Double maxValue, String exceptionClassName)

If the specified value is not a valid Double throw an exception.

Parameters
value Value to validate
locale The locale to use for the format
pattern The pattern used to format the value
minValue The minimum value
maxValue The maximum value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateEmail (String emailAddress, String exceptionClassName)

If the specified emailAddress is not a valid one throw an exception.

Parameters
emailAddress Email address to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateFloat (String value, Locale locale, String pattern, Float minValue, Float maxValue, String exceptionClassName)

If the specified value is not a valid Float throw an exception.

Parameters
value Value to validate
locale The locale to use for the format
pattern The pattern used to format the value
minValue The minimum value
maxValue The maximum value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateISBN10 (String isbnCode, String exceptionClassName)

If the specified isbnCode is not a valid one throw an exception.

Parameters
isbnCode ISBN code to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateISBN13 (String isbnCode, String exceptionClassName)

If the specified isbnCode is not a valid one throw an exception.

Parameters
isbnCode ISBN code to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateInteger (String value, Locale locale, String pattern, Integer minValue, Integer maxValue, String exceptionClassName)

If the specified value is not a valid Integer throw an exception.

Parameters
value Value to validate
locale The locale to use for the format
pattern The pattern used to format the value
minValue The minimum value
maxValue The maximum value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateIpAddress (String ipAddress, String exceptionClassName)

If the specified ipAddress is not a valid one throw an exception.

Parameters
ipAddress IP address to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateLong (String value, Locale locale, String pattern, Long minValue, Long maxValue, String exceptionClassName)

If the specified value is not a valid Long throw an exception.

Parameters
value Value to validate
locale The locale to use for the format
pattern The pattern used to format the value
minValue The minimum value
maxValue The maximum value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateNotEmpty (Object object, String exceptionClassName)

If the specified object is empty or null throw an exception.

Parameters
object Object to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validatePercentage (String percentage, String exceptionClassName)

If the specified percentage is not a valid one throw an exception.

Parameters
percentage Percentage to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateShort (String value, Locale locale, String pattern, Short minValue, Short maxValue, String exceptionClassName)

If the specified value is not a valid Short throw an exception.

Parameters
value Value to validate
locale The locale to use for the format
pattern The pattern used to format the value
minValue The minimum value
maxValue The maximum value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateTime (String time, Locale locale, String pattern, String exceptionClassName)

If the specified time is not a valid one throw an exception.

Parameters
time Time to validate
locale The locale to use for the format
pattern The pattern used to format the value
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateTopLevelDomain (String topLevelDomain, String exceptionClassName)

If if the specified topLevelDomain does not matches any IANA-defined top-level domain throw an exception. Leading dots are ignored if present. The search is case-sensitive.

Parameters
topLevelDomain Domain name to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateTopLevelDomainCountry (String countryCode, String exceptionClassName)

If if the specified countryCode does not matches any IANA-defined top-level domain throw an exception. Leading dots are ignored if present. The search is case-sensitive.

Parameters
countryCode Country code to validate
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateUrl (String url, boolean allowTwoSlashes, boolean allowAllSchemes, boolean allowLocalURLs, boolean noFragments, String exceptionClassName)

If the specified url is not a valid one throw an exception.

Parameters
url URL to validate
allowTwoSlashes Allow two slashes in the path component of the URL.
allowAllSchemes Allows all validly formatted schemes to pass validation instead of supplying a set of valid schemes.
allowLocalURLs Allow local URLs, such as http://localhost/ or http://machine/ .
noFragments Enabling this options disallows any URL fragments.
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception

public void validateUsingRegex (String value, List<String> regexs, boolean caseSensitive, String exceptionClassName)

If the specified value does not match any of the regexs then throw an exception.

Parameters
value Value to match
regexs Set of regular expressions to test against
caseSensitive When true matching is case sensitive, otherwise matching is case in-sensitive
exceptionClassName Class name of the exception to throw
Throws
InvalidException if not valid
Exception