ZsBT / mrz-java

Machine-Readable Zone parser for Java
71 stars 42 forks source link

checkdigit handling #20

Open ZsBT opened 7 years ago

ZsBT commented 7 years ago

As mentioned in https://github.com/ZsBT/mrz-java/issues/15#issuecomment-330182695 , what if we left the boolean validDateofBirth name in the result object as is, and introduced a new property "validCheckDigit" in MrzDate? Thus, validDateofBirth would mean there is something wrong: parse error and/or failed check digit validation. Shall we are interested in the exact cause, we can inspect further with isValidDate() and validCheckDigit of the MrzDate object. What do you think, does it make sense or it is overcomplicated now?

GoUpNorth commented 7 years ago

Hi, I agree with you on the fact that we need two different flags to differentiate the date validity status, and the date checkdigit status.

However, I think that the checkdigit flags shoud remain at the MrzRecord level, since they are related to the MRZ, and not to the dates or to the document numbers (there also is an checkdigit for the optional number in the MRTD TD3 MRZ). Also, if you want to put the checkdigit flag at the object level for the MrzDate, you will have to create another object for the document number and the optional, only to store that checksum flag. And the only object for which you need a validity flag is the date, since you can't verify that a document number is valid (apart frrom checking that it only contains capitalized letters and digits of course, but that is common to all the fields in the MRZ).

To summarize I would put the validity flag at the date level, and the checkdigit flag at the MrzRecord level.

P-A