# MRZParser **Repository Path**: raycen/MRZParser ## Basic Information - **Project Name**: MRZParser - **Description**: mirror MRZParser - **Primary Language**: Swift - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-09-20 - **Last Updated**: 2022-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![Build and test](https://github.com/appintheair/MRZParser/actions/workflows/Build%20and%20test.yml/badge.svg)](https://github.com/appintheair/MRZParser/actions/workflows/Build%20and%20test.yml) [![codecov](https://codecov.io/gh/appintheair/MRZParser/branch/develop/graph/badge.svg?token=XS5F9MtSfq)](https://codecov.io/gh/appintheair/MRZParser) [![spm](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/appintheair/MRZParser/blob/develop/Package.swift) # MRZParser [MRZ](https://en.wikipedia.org/wiki/Machine-readable_passport) 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](https://raw.githubusercontent.com/appintheair/MRZParser/develop/docs/img/Fields_Distribution.png) #### 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 ```swift 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. ```swift let parser = MRZParser() ``` For parsing, we use the `parse` method which returns the `MRZResult` structure with all the necessary data. ```swift parser.parse(mrzString: mrzString) ``` ## Example ### TD1 (ID card) #### Input ``` I