Aryan Ganjoo created VALIDATOR-510:
--------------------------------------

             Summary: IBANValidator.setValidator removes unrelated aliases when 
changing a secondary country code
                 Key: VALIDATOR-510
                 URL: https://issues.apache.org/jira/browse/VALIDATOR-510
             Project: Commons Validator
          Issue Type: Bug
            Reporter: Aryan Ganjoo


On current Commons Validator master, IBANValidator.setValidator treats a 
secondary country code as though it were the primary code of the previous 
validator. Replacing AX (an FI alias) with its own validator installs AX and 
then immediately deletes it. Removing GF (an FR alias) also removes GP and 
other FR aliases even though FR is still installed.

Reproduction: create a new IBANValidator, call setValidator(new 
IBANValidator.Validator("AX", 18, "AX\d{16}")), then check hasValidator("AX"): 
it is false. In a separate instance, call setValidator("GF", -1, null), then 
check hasValidator("GP"): it is false. Both should remain independently valid 
under the documented same-country-code replacement behavior.

A minimal local correction only clears secondary entries when 
replacing/removing the previous validator under its primary code, and only 
while each alias still maps to that previous validator. A standalone 
reproduction failed on the original source and passed with the patch. On the 
patched candidate, IBANValidatorTest passed 435 cases and the Maven test suite 
passed 3,197 tests with 3 skipped on JDK 17. No hosted CI or maintainer review 
yet.

AI Assistance used.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to