MRZ code parser for TD1(ID cards), TD2, TD3 (Passports), MRVA (Visas type A), MRVB (Visas type B) types.
| Field | TD1 description | TD2 description | TD3 description | MRVA description | MRVB description |
|---|---|---|---|---|---|
| Document type | The first letter shall be 'I', 'A' or 'C' | <- | Normally 'P' for passport | The First letter must be 'V' | <- |
| Country code | 3 letters code (ISO 3166-1) or country name (in English) | <- | <- | <- | <- |
| Document number | Document number | <- | <- | <- | <- |
| Birth date | Format: YYMMDD | <- | <- | <- | <- |
| Sex | Genre. Male: 'M', Female: 'F' or Undefined: 'X', "<" or "" | <- | <- | <- | <- |
| Expiry date | Format: YYMMDD | <- | <- | <- | <- |
| Nationality | 3 letters code (ISO 3166-1) or country name (in English) | <- | <- | <- | <- |
| Surname | Holder primary identifier(s) | <- | Primary identifier(s) | <- | <- |
| Given names | Holder secondary identifier(s) | <- | Secondary identifier(s) | <- | <- |
| Optional data | Optional personal data at the discretion of the issuing State. Non-mandatory field. | <- | Personal number. In some countries non-mandatory field. | Optional personal data at the discretion of the issuing State. Non-mandatory field. | <- |
| Optional data 2 | Optional personal data at the discretion of the issuing State. Non-mandatory field. | X | X | X | X |
dependencies: [
.package(url: "https://github.com/appintheair/MRZParser.git", .upToNextMajor(from: "1.1.2"))
]The parser is able to validate the MRZ string and parse the MRZ code. Let's start by initializing our parser.
let parser = MRZParser()For parsing, we use the parse method which returns the MRZResult structure with all the necessary data.
parser.parse(mrzString: mrzString)I<UTOD231458907<<<<<<<<<<<<<<<
7408122F1204159UTO<<<<<<<<<<<6
ERIKSSON<<ANNA<MARIA<<<<<<<<<<
| Field | Value |
|---|---|
| Document type | I |
| Country code | UTO |
| Document number | D23145890 |
| Birth date | 1974.08.12 |
| Sex | FEMALE |
| Expiry date | 2012.04.15 |
| Nationality | UTO |
| Surname | ERIKSSON |
| Given names | ANNA MARIA |
| Optional data | "" |
| Optional data 2 | "" |
I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<
D231458907UTO7408122F1204159<<<<<<<6
| Field | Value |
|---|---|
| Document type | I |
| Country code | UTO |
| Document number | D23145890 |
| Birth date | 1974.08.12 |
| Sex | FEMALE |
| Expiry date | 2012.04.15 |
| Nationality | UTO |
| Surname | ERIKSSON |
| Given names | ANNA MARIA |
| Optional data | "" |
P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L898902C36UTO7408122F1204159ZE184226B<<<<<10
| Field | Value |
|---|---|
| Document type | P |
| Country code | UTO |
| Document number | L898902C3 |
| Birth date | 1974.08.12 |
| Sex | FEMALE |
| Expiry date | 2012.04.15 |
| Nationality | UTO |
| Surname | ERIKSSON |
| Given names | ANNA MARIA |
| Optional data | ZE184226B |
V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L8988901C4XXX4009078F96121096ZE184226B<<<<<<
| Field | Value |
|---|---|
| Document type | V |
| Country code | UTO |
| Document number | L8988901C |
| Birth date | 1940.09.07 |
| Sex | FEMALE |
| Expiry date | 1996.12.10 |
| Nationality | XXX |
| Surname | ERIKSSON |
| Given names | ANNA MARIA |
| Optional data | 6ZE184226B |
V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<
L8988901C4XXX4009078F9612109<<<<<<<<
| Field | Value |
|---|---|
| Document type | V |
| Country code | UTO |
| Document number | L8988901C |
| Birth date | 1940.09.07 |
| Sex | FEMALE |
| Expiry date | 1996.12.10 |
| Nationality | XXX |
| Surname | ERIKSSON |
| Given names | ANNA MARIA |
| Optional data | "" |
The library is distributed under the MIT LICENSE.