Hi,
This link show how to create a validator to validate EAN-13 codes (numeric,
with a length of 13)
http://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/package-summary.html#other.code
However I tested the method and always returns "false", like this...
public boolean isCodeEAN13Valid(String code) {
CodeValidator validator = new CodeValidator("^[0-9]*$", 13,
EAN13CheckDigit.EAN13_CHECK_DIGIT); return = validator.isValid(code);
}
@Test
public void shouldBeAnValidCodeEAN13() {
assertTrue(object.isCodeEAN13Valid("7501031311309"));
}
1. Note that I used EAN13CheckDigit.EAN13_CHECK_DIGIT and not
EAN13CheckDigit.INSTANCE.
2. I did not found information about EAN13CheckDigit.INSTANCE. Is it from
what release of commons.validator?
3. My constructor of CodeValidator and how it was applied and used in
example is really right?
Thank you
Bispo, Rodrigo