Class IBANValidator
java.lang.Object
org.apache.commons.validator.routines.IBANValidator
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final IBANValidator.Validator[]static final IBANValidatorprivate final Map<String, IBANValidator.Validator> -
Constructor Summary
ConstructorsConstructorDescriptionCreate a default IBAN validator.IBANValidator(IBANValidator.Validator[] formatMap) Create an IBAN validator from the specified map of IBAN formats. -
Method Summary
Modifier and TypeMethodDescriptionprivate Map<String, IBANValidator.Validator> createValidators(IBANValidator.Validator[] formatMap) Gets a copy of the default Validators.static IBANValidatorReturn a singleton instance of the IBAN validator using the default formatsgetValidator(String code) Get the Validator for a given IBANbooleanhasValidator(String code) Does the class have the required validator?booleanValidate an IBAN Code.setValidator(String countryCode, int length, String format) Installs a validator.setValidator(IBANValidator.Validator validator) Installs a validator.
-
Field Details
-
formatValidators
-
DEFAULT_FORMATS
-
DEFAULT_IBAN_VALIDATOR
-
-
Constructor Details
-
IBANValidator
public IBANValidator()Create a default IBAN validator. -
IBANValidator
Create an IBAN validator from the specified map of IBAN formats.- Parameters:
formatMap- map of IBAN formats
-
-
Method Details
-
getInstance
Return a singleton instance of the IBAN validator using the default formats- Returns:
- A singleton instance of the ISBN validator
-
createValidators
-
isValid
Validate an IBAN Code.
- Parameters:
value- The value validation is being performed on- Returns:
trueif the value is valid
-
hasValidator
Does the class have the required validator?- Parameters:
code- the code to check- Returns:
- true if there is a validator
-
getDefaultValidators
Gets a copy of the default Validators.- Returns:
- a copy of the default Validator array
-
getValidator
Get the Validator for a given IBAN- Parameters:
code- a string starting with the ISO country code (e.g. an IBAN)- Returns:
- the validator or
nullif there is not one registered.
-
setValidator
Installs a validator. Will replace any existing entry which has the same countryCode- Parameters:
validator- the instance to install.- Returns:
- the previous Validator, or
nullif there was none - Throws:
IllegalStateException- if an attempt is made to modify the singleton validator
-
setValidator
Installs a validator. Will replace any existing entry which has the same countryCode.- Parameters:
countryCode-length- the length of the IBAN. Must be ≥ 8 and ≤ 32. If the length is < 0, the validator is removed, and the format is not used.format- the format of the IBAN (as a regular expression)- Returns:
- the previous Validator, or
nullif there was none - Throws:
IllegalArgumentException- if there is a problemIllegalStateException- if an attempt is made to modify the singleton validator
-