sahvx655-wq opened a new pull request, #399:
URL: https://github.com/apache/commons-validator/pull/399
**ISIN country code read from the raw argument**
Whilst checking the country-code path I noticed that `isValid`/`validate`
disagree with the underlying `CodeValidator` for inputs with surrounding
whitespace. The validator trims the argument before matching, so `validate("
US0378331005")` returns the trimmed `US0378331005`, but the ISO-3166 lookup
then takes `code.substring(0, 2)` from the original untrimmed string and reads
`" U"`, which is not a country code. The upshot is that the same valid ISIN
passes with `getInstance(false)` yet is rejected by `getInstance(true)`.
The root cause is the country code being derived from the raw argument
rather than from the code the validator actually accepted. Reading it from the
validated value keeps both code paths consistent. Left unfixed, callers that
enable the country check silently reject otherwise-valid codes purely on the
presence of leading whitespace. Added a regression test for the trimmed lookup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]