Swiftpack.co -  appintheair/MRZParser as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
appintheair/MRZParser
MRZ (Machine Readable Zones) code parser for TD1 (ID cards), TD2, TD3 (Passports), MRVA (Visas type A), MRVB (Visas type B) types.
.package(url: "https://github.com/appintheair/MRZParser.git", from: "v1.1.0")

Build and test codecov spm

MRZParser

MRZ code parser for TD1(ID cards), TD2, TD3 (Passports), MRVA (Visas type A), MRVB (Visas type B) types.

Fields Distribution of Official Travel Documents:

image

Fields description

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

Installation guide

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/appintheair/MRZParser.git", .upToNextMajor(from: "0.0.1"))
]

Usage

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)

Example

TD1 (ID card)

Input

I<UTOD231458907<<<<<<<<<<<<<<<
7408122F1204159UTO<<<<<<<<<<<6
ERIKSSON<<ANNA<MARIA<<<<<<<<<<

Output

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 ""

TD2

Input

I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<
D231458907UTO7408122F1204159<<<<<<<6

Output

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 ""

TD3 (Passport)

Input

P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L898902C36UTO7408122F1204159ZE184226B<<<<<10

Output

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

MRVA (Visa type A)

Input

V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L8988901C4XXX4009078F96121096ZE184226B<<<<<<

Output

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

MRVB (Visa type B)

Input

V<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<
L8988901C4XXX4009078F9612109<<<<<<<<

Output

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 ""

License

The library is distributed under the MIT LICENSE.

GitHub

link
Stars: 4
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Version 1.1.0
1 week ago

Add test and refactor all codebase

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API