Giter VIP home page Giter VIP logo

mrzparser's Introduction

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: "1.1.2"))
]

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.

mrzparser's People

Contributors

serejaonly avatar magauran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.