├── DLP.Core ├── driving-license.ico ├── driving-license.png ├── Models │ ├── Enums │ │ ├── Truncation.cs │ │ ├── Gender.cs │ │ ├── IssuingCountry.cs │ │ ├── NamePart.cs │ │ ├── HairColor.cs │ │ ├── LicenseVersion.cs │ │ ├── EyeColor.cs │ │ └── NameSuffix.cs │ └── DriversLicenseData.cs ├── Interfaces │ ├── IDriversLicenseParser.cs │ └── IParseableLicense.cs ├── ParseableLicenses │ ├── Yukon.cs │ ├── Guam.cs │ ├── Iowa.cs │ ├── Quebec.cs │ ├── Alaska.cs │ ├── Alberta.cs │ ├── Coahuila.cs │ ├── Hawaii.cs │ ├── Hidalgo.cs │ ├── Idaho.cs │ ├── Kansas.cs │ ├── Maine.cs │ ├── Manitoba.cs │ ├── Nevada.cs │ ├── Nunavut.cs │ ├── Ontario.cs │ ├── Texas.cs │ ├── Alabama.cs │ ├── Arizona.cs │ ├── Arkansas.cs │ ├── Colorado.cs │ ├── Delaware.cs │ ├── Florida.cs │ ├── Georgia.cs │ ├── Indiana.cs │ ├── Kentucky.cs │ ├── Maryland.cs │ ├── Missouri.cs │ ├── Montana.cs │ ├── Nebraska.cs │ ├── NewYork.cs │ ├── Oklahoma.cs │ ├── Vermont.cs │ ├── Virginia.cs │ ├── Louisiana.cs │ ├── NewJersey.cs │ ├── NewMexico.cs │ ├── NovaScotia.cs │ ├── Tennessee.cs │ ├── Wisconsin.cs │ ├── California.cs │ ├── Mississippi.cs │ ├── NewBrunswick.cs │ ├── NorthDakota.cs │ ├── PuertoRico.cs │ ├── RhodeIsland.cs │ ├── Saskatchewan.cs │ ├── SouthDakota.cs │ ├── Massachusetts.cs │ ├── NewHampshire.cs │ ├── WestVirginia.cs │ ├── AmericanSamoa.cs │ ├── BritishColumbia.cs │ ├── SouthCarolina.cs │ ├── VirginIslands.cs │ ├── PrinceEdwardIsland.cs │ ├── DistrictOfColumbia.cs │ ├── NewfoundlandAndLabrador.cs │ ├── NorthernMariannaIslands.cs │ ├── StateDeptDiplomatic.cs │ ├── Utah.cs │ ├── Illinois.cs │ ├── Michigan.cs │ ├── Minnesota.cs │ ├── Connecticut.cs │ ├── Pennsylvania.cs │ ├── Oregon.cs │ ├── Washington.cs │ ├── Wyoming.cs │ ├── NorthCarolina.cs │ └── Ohio.cs ├── .nuspec ├── Helpers │ ├── Constants.cs │ └── StartupExtensions.cs ├── Exceptions │ └── LicenseFormatException.cs ├── DriversLicenseParser.cs ├── README.md ├── DLP.Core.csproj └── Parsers │ ├── Version5StandardParser.cs │ ├── Version6StandardParser.cs │ ├── Version7StandardParser.cs │ ├── Version8StandardParser.cs │ ├── Version9StandardParser.cs │ ├── Version4StandardParser.cs │ └── Version3StandardParser.cs ├── SECURITY.md ├── DLP.Lambda ├── Properties │ └── launchSettings.json ├── Dockerfile ├── DLP.Lambda.csproj ├── aws-lambda-tools-defaults.json ├── Function.cs └── Readme.md ├── .github ├── workflows │ ├── dotnet.yml │ └── code_quality.yml ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── bug_report.md ├── DLP.Tests ├── Helpers │ └── ConstantsTests.cs ├── DLP.Tests.csproj ├── Exceptions │ └── LicenseFormatExceptionTests.cs ├── DriversLicenseParserTests.cs └── ParseableLicenses │ ├── NorthCarolinaTests.cs │ ├── UtahTests.cs │ ├── IllinoisTests.cs │ └── ConnecticutTests.cs ├── DriversLicenseParser.sln.DotSettings ├── .vscode ├── launch.json └── tasks.json ├── README.md ├── DriversLicenseParser.sln └── .gitignore /DLP.Core/driving-license.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joshuaquiz/DriversLicenseParser/HEAD/DLP.Core/driving-license.ico -------------------------------------------------------------------------------- /DLP.Core/driving-license.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joshuaquiz/DriversLicenseParser/HEAD/DLP.Core/driving-license.png -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 1.0.0.0 | :white_check_mark: | 8 | 9 | ## Reporting a Vulnerability 10 | 11 | To report a vulnerability create an issue in the issue tracker project. I will try to get back as soon as I can. 12 | -------------------------------------------------------------------------------- /DLP.Lambda/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Mock Lambda Test Tool": { 4 | "commandName": "Executable", 5 | "commandLineArgs": "--port 5050", 6 | "workingDirectory": ".\\bin\\$(Configuration)\\net6.0", 7 | "executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-6.0.exe" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v2 18 | with: 19 | dotnet-version: 7.0.x 20 | - name: Restore dependencies 21 | run: dotnet restore 22 | - name: Build 23 | run: dotnet build --no-restore 24 | - name: Test 25 | run: dotnet test --no-build --verbosity normal 26 | -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/Truncation.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA Name Truncations:
5 | /// - Unknown: When the truncation cannot be determined
6 | /// - Truncated: The name was truncated
7 | /// - None: The name was not truncated
8 | ///
9 | public enum Truncation 10 | { 11 | /// 12 | /// Unknown Truncation. 13 | /// 14 | Unknown, 15 | 16 | /// 17 | /// Truncated Name. 18 | /// 19 | Truncated, 20 | 21 | /// 22 | /// Not Truncated. 23 | /// 24 | None 25 | } -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/Gender.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA Genders:
5 | /// - Unknown: When the gender cannot be determined
6 | /// - Male: Male
7 | /// - Female: Female
8 | /// - Other: Not yet part of the AAMVA spec
9 | ///
10 | public enum Gender 11 | { 12 | /// 13 | /// Unknown Gender. 14 | /// 15 | Unknown, 16 | 17 | /// 18 | /// Male. 19 | /// 20 | Male, 21 | 22 | /// 23 | /// Female. 24 | /// 25 | Female, 26 | 27 | /// 28 | /// Other. 29 | /// 30 | Other 31 | } -------------------------------------------------------------------------------- /DLP.Core/Interfaces/IDriversLicenseParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Exceptions; 2 | using DLP.Core.Models; 3 | using System; 4 | 5 | namespace DLP.Core.Interfaces; 6 | 7 | /// 8 | /// Drivers license parser. 9 | /// 10 | public interface IDriversLicenseParser 11 | { 12 | /// 13 | /// Attempts to parse the license data. 14 | /// 15 | /// The license data. 16 | /// Thrown if the provided data is empty or null. 17 | /// Thrown if the data could not be matched to any known format. 18 | /// 19 | public DriversLicenseData Parse(string? data); 20 | } -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/IssuingCountry.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA Issuing Countries:
5 | /// - Unknown: When the issuing country is not available
6 | /// - UnitedStates: The USA
7 | /// - Canada: Canada, eh?
8 | /// - Mexico: Unknown AAMVA status
9 | ///
10 | public enum IssuingCountry 11 | { 12 | /// 13 | /// Unknown Issuing Country. 14 | /// 15 | Unknown, 16 | 17 | /// 18 | /// The United States. 19 | /// 20 | UnitedStates, 21 | 22 | /// 23 | /// Canada, eh? 24 | /// 25 | Canada, 26 | 27 | /// 28 | /// Mexico: Unknown AAMVA status 29 | /// 30 | Mexico 31 | } -------------------------------------------------------------------------------- /.github/workflows/code_quality.yml: -------------------------------------------------------------------------------- 1 | name: Qodana 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | - 'releases/*' 9 | 10 | jobs: 11 | qodana: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | contents: write 15 | pull-requests: write 16 | checks: write 17 | steps: 18 | - uses: actions/checkout@v3 19 | with: 20 | ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit 21 | fetch-depth: 0 # a full history is required for pull request analysis 22 | - name: 'Qodana Scan' 23 | uses: JetBrains/qodana-action@v2023.2 24 | env: 25 | QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} # read the steps about it below 26 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: g3software 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /DLP.Lambda/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM public.ecr.aws/lambda/dotnet:6 2 | 3 | WORKDIR /var/task 4 | 5 | # This COPY command copies the .NET Lambda project's build artifacts from the host machine into the image. 6 | # The source of the COPY should match where the .NET Lambda project publishes its build artifacts. If the Lambda function is being built 7 | # with the AWS .NET Lambda Tooling, the `--docker-host-build-output-dir` switch controls where the .NET Lambda project 8 | # will be built. The .NET Lambda project templates default to having `--docker-host-build-output-dir` 9 | # set in the aws-lambda-tools-defaults.json file to "bin/Release/lambda-publish". 10 | # 11 | # Alternatively Docker multi-stage build could be used to build the .NET Lambda project inside the image. 12 | # For more information on this approach checkout the project's README.md file. 13 | COPY "bin/Release/lambda-publish" . 14 | -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/NamePart.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// Represents the different parts of a name that can be parsed. 5 | /// 6 | public enum NamePart 7 | { 8 | /// 9 | /// Unknown name type. 10 | /// 11 | Undefined, 12 | 13 | /// 14 | /// Used to try to extract the first name. 15 | /// 16 | FirstName, 17 | 18 | /// 19 | /// Used to try to extract the middle name. 20 | /// 21 | MiddleName, 22 | 23 | /// 24 | /// Used to try to extract a short middle name. 25 | /// 26 | ShortMiddleName, 27 | 28 | /// 29 | /// Used to try to extract the last name. 30 | /// 31 | LastName, 32 | 33 | /// 34 | /// Used to try to extract the suffix. 35 | /// 36 | Suffix 37 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Yukon.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Yukon : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Yukon"; 12 | 13 | /// 14 | public string Abbreviation => "YT"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604429; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Guam.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Guam : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Guam"; 12 | 13 | /// 14 | public string Abbreviation => "GU"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636019; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Iowa.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Iowa : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Iowa"; 12 | 13 | /// 14 | public string Abbreviation => "IA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636018; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Quebec.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Quebec : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Quebec"; 12 | 13 | /// 14 | public string Abbreviation => "QC"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604428; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Alaska.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Alaska : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Alaska"; 12 | 13 | /// 14 | public string Abbreviation => "AK"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636059; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Alberta.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Alberta : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Alberta"; 12 | 13 | /// 14 | public string Abbreviation => "AB"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604432; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Coahuila.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Coahuila : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Coahuila"; 12 | 13 | /// 14 | public string Abbreviation => "CU"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Mexico; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636056; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Hawaii.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Hawaii : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Hawaii"; 12 | 13 | /// 14 | public string Abbreviation => "HI"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636047; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Hidalgo.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Hidalgo : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Hidalgo"; 12 | 13 | /// 14 | public string Abbreviation => "HL"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Mexico; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636057; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Idaho.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Idaho : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Idaho"; 12 | 13 | /// 14 | public string Abbreviation => "ID"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636050; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Kansas.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Kansas : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Kansas"; 12 | 13 | /// 14 | public string Abbreviation => "KS"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636022; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Maine.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Maine : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Maine"; 12 | 13 | /// 14 | public string Abbreviation => "ME"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636041; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Manitoba.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Manitoba : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Manitoba"; 12 | 13 | /// 14 | public string Abbreviation => "MB"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636048; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Nevada.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Nevada : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Nevada"; 12 | 13 | /// 14 | public string Abbreviation => "NV"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636049; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Nunavut.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Nunavut : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Nunavut"; 12 | 13 | /// 14 | public string Abbreviation => "NU"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604433; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Ontario.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Ontario : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Ontario"; 12 | 13 | /// 14 | public string Abbreviation => "ON"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636012; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Texas.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Texas : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Texas"; 12 | 13 | /// 14 | public string Abbreviation => "TX"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636015; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Alabama.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Alabama : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Alabama"; 12 | 13 | /// 14 | public string Abbreviation => "AL"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636033; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Arizona.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Arizona : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Arizona"; 12 | 13 | /// 14 | public string Abbreviation => "AZ"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636026; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Arkansas.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Arkansas : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Arkansas"; 12 | 13 | /// 14 | public string Abbreviation => "AR"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636021; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Colorado.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Colorado : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Colorado"; 12 | 13 | /// 14 | public string Abbreviation => "CO"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636020; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Delaware.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Delaware : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Delaware"; 12 | 13 | /// 14 | public string Abbreviation => "DE"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636011; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Florida.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Florida : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Florida"; 12 | 13 | /// 14 | public string Abbreviation => "FL"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636010; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Georgia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Georgia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Georgia"; 12 | 13 | /// 14 | public string Abbreviation => "GA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636055; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Indiana.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Indiana : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Indiana"; 12 | 13 | /// 14 | public string Abbreviation => "IN"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636037; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Kentucky.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Kentucky : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Kentucky"; 12 | 13 | /// 14 | public string Abbreviation => "KY"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636046; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Maryland.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Maryland : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Maryland"; 12 | 13 | /// 14 | public string Abbreviation => "MD"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636003; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Missouri.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Missouri : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Missouri"; 12 | 13 | /// 14 | public string Abbreviation => "MO"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636030; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Montana.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Montana : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Montana"; 12 | 13 | /// 14 | public string Abbreviation => "MT"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636008; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Nebraska.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Nebraska : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Nebraska"; 12 | 13 | /// 14 | public string Abbreviation => "NE"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636054; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewYork.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewYork : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "New York"; 12 | 13 | /// 14 | public string Abbreviation => "NY"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636001; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Oklahoma.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Oklahoma : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Oklahoma"; 12 | 13 | /// 14 | public string Abbreviation => "OK"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636058; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Vermont.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Vermont : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Vermont"; 12 | 13 | /// 14 | public string Abbreviation => "VT"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636024; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Virginia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Virginia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Virginia"; 12 | 13 | /// 14 | public string Abbreviation => "VA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636000; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Louisiana.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Louisiana : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Louisiana"; 12 | 13 | /// 14 | public string Abbreviation => "LA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636007; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewJersey.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewJersey : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "New Jersey"; 12 | 13 | /// 14 | public string Abbreviation => "NJ"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636036; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewMexico.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewMexico : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "New Mexico"; 12 | 13 | /// 14 | public string Abbreviation => "NM"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636009; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NovaScotia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NovaScotia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Nova Scotia"; 12 | 13 | /// 14 | public string Abbreviation => "NS"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636013; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Tennessee.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Tennessee : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Tennessee"; 12 | 13 | /// 14 | public string Abbreviation => "TN"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636053; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Wisconsin.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Wisconsin : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Wisconsin"; 12 | 13 | /// 14 | public string Abbreviation => "WI"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636031; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/California.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class California : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "California"; 12 | 13 | /// 14 | public string Abbreviation => "CA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636014; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Mississippi.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Mississippi : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Mississippi"; 12 | 13 | /// 14 | public string Abbreviation => "MS"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636051; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewBrunswick.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewBrunswick : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "New Brunswick"; 12 | 13 | /// 14 | public string Abbreviation => "NB"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636017; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NorthDakota.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NorthDakota : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "North Dakota"; 12 | 13 | /// 14 | public string Abbreviation => "ND"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636034; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/PuertoRico.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class PuertoRico : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Puerto Rico"; 12 | 13 | /// 14 | public string Abbreviation => "PR"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604431; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/RhodeIsland.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class RhodeIsland : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Rhode Island"; 12 | 13 | /// 14 | public string Abbreviation => "RI"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636052; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Saskatchewan.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Saskatchewan : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Saskatchewan"; 12 | 13 | /// 14 | public string Abbreviation => "SK"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636044; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/SouthDakota.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class SouthDakota : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "South Dakota"; 12 | 13 | /// 14 | public string Abbreviation => "SD"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636042; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Massachusetts.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class Massachusetts : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Massachusetts"; 12 | 13 | /// 14 | public string Abbreviation => "MA"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636002; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewHampshire.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewHampshire : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "New Hampshire"; 12 | 13 | /// 14 | public string Abbreviation => "NH"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636039; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/WestVirginia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class WestVirginia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "West Virginia"; 12 | 13 | /// 14 | public string Abbreviation => "WV"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636061; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Tests/Helpers/ConstantsTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using FluentAssertions; 3 | using Xunit; 4 | 5 | namespace DLP.Tests.Helpers; 6 | 7 | public static class ConstantsTests 8 | { 9 | [Fact] 10 | public static void LicenseFormatExceptionHelpUrlIsCorrect() => 11 | Constants.LicenseFormatExceptionHelpUrl 12 | .ToString() 13 | .Should() 14 | .Be("https://github.com/joshuaquiz/DriversLicenseParser/wiki/License-Data-Formatting"); 15 | 16 | [Fact] 17 | public static void InchesPerCentimeterIsCorrect() => 18 | Constants.InchesPerCentimeter 19 | .Should() 20 | .Be(0.393701M); 21 | 22 | [Fact] 23 | public static void ErrorMessagesLicenseFormatExceptionMessageIsCorrect() => 24 | Constants.ErrorMessages.LicenseFormatExceptionMessage 25 | .Should() 26 | .Be("The provided data could not be matched to a known format."); 27 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/AmericanSamoa.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class AmericanSamoa : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "American Samoa"; 12 | 13 | /// 14 | public string Abbreviation => "AS"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604427; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/BritishColumbia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class BritishColumbia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "British Columbia"; 12 | 13 | /// 14 | public string Abbreviation => "BC"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636028; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/SouthCarolina.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class SouthCarolina : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "South Carolina"; 12 | 13 | /// 14 | public string Abbreviation => "SC"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636005; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/VirginIslands.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class VirginIslands : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Virgin Islands"; 12 | 13 | /// 14 | public string Abbreviation => "VI"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636062; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/PrinceEdwardIsland.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class PrinceEdwardIsland : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Prince Edward Island "; 12 | 13 | /// 14 | public string Abbreviation => "PE"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604426; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/DistrictOfColumbia.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class DistrictOfColumbia : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "District of Columbia"; 12 | 13 | /// 14 | public string Abbreviation => "DC"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636043; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NewfoundlandAndLabrador.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NewfoundlandAndLabrador : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Newfoundland and Labrador"; 12 | 13 | /// 14 | public string Abbreviation => "NL"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.Canada; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636016; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NorthernMariannaIslands.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class NorthernMariannaIslands : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "Northern Marianna Islands"; 12 | 13 | /// 14 | public string Abbreviation => "MP"; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 604430; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/StateDeptDiplomatic.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | public sealed class StateDeptDiplomatic : IParseableLicense 9 | { 10 | /// 11 | public string FullName => "State Dept. (Diplomatic)"; 12 | 13 | /// 14 | public string Abbreviation => string.Empty; 15 | 16 | /// 17 | public IssuingCountry Country => IssuingCountry.UnitedStates; 18 | 19 | /// 20 | public int IssuerIdentificationNumber => 636027; 21 | 22 | /// 23 | public bool IsDataFromEntity(string? data) => 24 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 25 | 26 | /// 27 | public DriversLicenseData ParseData(string? data) => 28 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 29 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Utah.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Utah. 10 | /// 11 | public sealed class Utah : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Utah"; 15 | 16 | /// 17 | public string Abbreviation => "UT"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636040; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) => 31 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 32 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Illinois.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Illinois. 10 | /// 11 | public sealed class Illinois : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Illinois"; 15 | 16 | /// 17 | public string Abbreviation => "IL"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636035; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) => 31 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 32 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Michigan.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Michigan. 10 | /// 11 | public sealed class Michigan : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Michigan"; 15 | 16 | /// 17 | public string Abbreviation => "MI"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636032; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) => 31 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 32 | } -------------------------------------------------------------------------------- /DLP.Core/.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DriversLicenseParser 5 | 1.0.0 6 | Parses drivers licenses data scanned from barcode 7 | Joshua Galloway 8 | https://github.com/joshuaquiz/DriversLicenseParser 9 | AGPL-3.0-or-later 10 | driving-license.png 11 | README.md 12 | true 13 | 14 | Initial package creation and nuget/github field updates. 15 | 16 | aamva drivers-licenses 17 | 18 | Drivers License Parser 19 | 20 | -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Minnesota.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Minnesota. 10 | /// 11 | public sealed class Minnesota : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Minnesota"; 15 | 16 | /// 17 | public string Abbreviation => "MN"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636038; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) => 31 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 32 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Connecticut.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Connecticut. 10 | /// 11 | public sealed class Connecticut : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Connecticut"; 15 | 16 | /// 17 | public string Abbreviation => "CT"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636006; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) => 31 | ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 32 | } -------------------------------------------------------------------------------- /DLP.Core/Helpers/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DLP.Core.Helpers; 4 | 5 | /// 6 | /// Constants for this project. 7 | /// 8 | public static class Constants 9 | { 10 | /// 11 | /// The project wiki URL. 12 | /// 13 | public static readonly Uri LicenseFormatExceptionHelpUrl = 14 | new("https://github.com/joshuaquiz/DriversLicenseParser/wiki/License-Data-Formatting", UriKind.Absolute); 15 | 16 | /// 17 | /// A double that represents how man inches are in a centimeter. 18 | /// 19 | public const decimal InchesPerCentimeter = 0.393701M; 20 | 21 | /// 22 | /// All Error messages should be here. 23 | /// 24 | public static class ErrorMessages 25 | { 26 | /// 27 | /// The provided data could not be matched to a known format. 28 | /// 29 | public const string LicenseFormatExceptionMessage = 30 | "The provided data could not be matched to a known format."; 31 | } 32 | } -------------------------------------------------------------------------------- /DLP.Core/Exceptions/LicenseFormatException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DLP.Core.Helpers; 3 | 4 | namespace DLP.Core.Exceptions; 5 | 6 | /// 7 | /// Exception: The provided data could not be matched to a known format. 8 | /// 9 | [Serializable] 10 | public sealed class LicenseFormatException : Exception 11 | { 12 | /// 13 | /// The raw string that was trying to be parsed. 14 | /// 15 | public string? LicenseData { get; } 16 | 17 | /// 18 | /// The provided data could not be matched to a known format. 19 | /// 20 | /// The raw string that was trying to be parsed. 21 | public LicenseFormatException(string? data) 22 | : base(Constants.ErrorMessages.LicenseFormatExceptionMessage) 23 | { 24 | LicenseData = data; 25 | HelpLink = Constants.LicenseFormatExceptionHelpUrl.ToString(); 26 | } 27 | 28 | /// 29 | public override string ToString() => 30 | $"{Message}{Environment.NewLine}License Data: {LicenseData}{Environment.NewLine}{StackTrace}"; 31 | } -------------------------------------------------------------------------------- /DLP.Lambda/DLP.Lambda.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net9.0 4 | enable 5 | enable 6 | true 7 | Lambda 8 | 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DLP.Tests/DLP.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net9.0 4 | false 5 | enable 6 | disable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | all 16 | 17 | 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | all 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /DriversLicenseParser.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True 4 | True 5 | True 6 | True 7 | True 8 | True 9 | True 10 | True -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/DLP.Tests/bin/Debug/netcoreapp3.1/DLP.Tests.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/DLP.Tests", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach", 24 | "processId": "${command:pickProcess}" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /DLP.Core/DriversLicenseParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using DLP.Core.Exceptions; 5 | using DLP.Core.Interfaces; 6 | using DLP.Core.Models; 7 | 8 | namespace DLP.Core; 9 | 10 | /// 11 | /// Drivers license parser entry point. 12 | /// 13 | public sealed class DriversLicenseParser : IDriversLicenseParser 14 | { 15 | private readonly IReadOnlyCollection? _parseableLicenses; 16 | 17 | /// 18 | /// Drivers license parser entry ctor. 19 | /// 20 | /// All parseable licenses. 21 | public DriversLicenseParser(IEnumerable? parseableLicenses) 22 | { 23 | _parseableLicenses = parseableLicenses?.ToList(); 24 | } 25 | 26 | /// 27 | public DriversLicenseData Parse(string? data) 28 | { 29 | if (string.IsNullOrWhiteSpace(data)) 30 | { 31 | throw new ArgumentNullException(nameof(data)); 32 | } 33 | 34 | var license = _parseableLicenses?.FirstOrDefault(x => x.IsDataFromEntity(data)) 35 | ?? throw new LicenseFormatException(data); 36 | return license.ParseData(data); 37 | } 38 | } -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/HairColor.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA hair colors:
5 | /// - Unknown: Unknown hair color
6 | /// - Bald: Bald hair
7 | /// - Black: Black hair
8 | /// - Blond: Blond hair
9 | /// - Brown: Brown hair
10 | /// - Grey: Grey hair
11 | /// - Red: Red hair
12 | /// - Sandy: Sandy hair
13 | /// - White: White hair
14 | ///
15 | public enum HairColor 16 | { 17 | /// 18 | /// Unknown hair color. 19 | /// 20 | Unknown, 21 | 22 | /// 23 | /// Bald hair color. 24 | /// 25 | Bald, 26 | 27 | /// 28 | /// Black hair color. 29 | /// 30 | Black, 31 | 32 | /// 33 | /// Blond hair color. 34 | /// 35 | Blond, 36 | 37 | /// 38 | /// Brown hair color. 39 | /// 40 | Brown, 41 | 42 | /// 43 | /// Grey hair color. 44 | /// 45 | Grey, 46 | 47 | /// 48 | /// Red hair color. 49 | /// 50 | Red, 51 | 52 | /// 53 | /// Sandy hair color. 54 | /// 55 | Sandy, 56 | 57 | /// 58 | /// White hair color. 59 | /// 60 | White 61 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: joshuaquiz 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Drivers license** 14 | Please include the state and any information that was wrong (please do not post full un-redacted images or payloads as this is a public repo). A good way to do this is to look at the tests and see the standard data we use to replace personal data then you can say John Doe was returned as Doe John. 15 | 16 | **To Reproduce** 17 | Steps to reproduce the behavior: 18 | 1. Go to '...' 19 | 2. Click on '....' 20 | 3. Scroll down to '....' 21 | 4. See error 22 | 23 | **Expected behavior** 24 | A clear and concise description of what you expected to happen. 25 | 26 | **Screenshots** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Desktop (please complete the following information):** 30 | - OS: [e.g. iOS] 31 | - Browser [e.g. chrome, safari] 32 | - Version [e.g. 22] 33 | 34 | **Smartphone (please complete the following information):** 35 | - Device: [e.g. iPhone6] 36 | - OS: [e.g. iOS8.1] 37 | - Browser [e.g. stock browser, safari] 38 | - Version [e.g. 22] 39 | 40 | **Additional context** 41 | Add any other context about the problem here. 42 | -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/LicenseVersion.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// The AAMVA versions:
5 | /// - Unknown Version
6 | /// - Version 1
7 | /// - Version 2
8 | /// - Version 3
9 | /// - Version 4
10 | /// - Version 5
11 | /// - Version 6
12 | /// - Version 7
13 | /// - Version 8
14 | /// - Version 9
15 | ///
16 | public enum LicenseVersion 17 | { 18 | /// 19 | /// Unknown Version. 20 | /// 21 | UnknownVersion, 22 | 23 | /// 24 | /// Version 1. 25 | /// 26 | Version1, 27 | 28 | /// 29 | /// Version 2. 30 | /// 31 | Version2, 32 | 33 | /// 34 | /// Version 3. 35 | /// 36 | Version3, 37 | 38 | /// 39 | /// Version 4. 40 | /// 41 | Version4, 42 | 43 | /// 44 | /// Version 5. 45 | /// 46 | Version5, 47 | 48 | /// 49 | /// Version 6. 50 | /// 51 | Version6, 52 | 53 | /// 54 | /// Version 7. 55 | /// 56 | Version7, 57 | 58 | /// 59 | /// Version 8. 60 | /// 61 | Version8, 62 | 63 | /// 64 | /// Version 9. 65 | /// 66 | Version9 67 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/DLP.Tests/DLP.Tests.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/DLP.Tests/DLP.Tests.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "${workspaceFolder}/DLP.Tests/DLP.Tests.csproj", 36 | "/property:GenerateFullPaths=true", 37 | "/consoleloggerparameters:NoSummary" 38 | ], 39 | "problemMatcher": "$msCompile" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/joshuaquiz/DriversLicenseParser/blob/main/LICENSE) 2 | [![.NET](https://github.com/joshuaquiz/DriversLicenseParser/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/joshuaquiz/DriversLicenseParser/actions/workflows/dotnet.yml) 3 | 4 | # Drivers License Parser 5 | 6 | Drivers licenses in the USA/Canada are all over the map and there are some suggestions that states follow but not all of them. How do you handle these differences? You could write and maintain this on your own or use an API that can parse the data from the bar code. If you want to do the former then feel free to copy this code, it is offered as is. If you want to use an API you can see the below documentation on how to do that. 7 | 8 | # More in-depth information 9 | 10 | For more information about formatting, data, questions, etc [visit the wiki](https://github.com/joshuaquiz/DriversLicenseParser/wiki) 11 | 12 | # Credits 13 | 14 | Credit to [@ksoftllc](https://github.com/ksoftllc) and his Swift library that I used to copy some of the parts that I did not have examples for - https://github.com/ksoftllc/license-parser 15 | 16 | Driving license icons created by [Freepik - Flaticon](https://www.flaticon.com/free-icons/driving-license) 17 | 18 | # Support 19 | If you want to support my work click here: [Sponsor joshuaquiz](https://github.com/sponsors/joshuaquiz) 20 | -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Pennsylvania.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Pennsylvania. 10 | /// 11 | public sealed class Pennsylvania : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Pennsylvania"; 15 | 16 | /// 17 | public string Abbreviation => "PA"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636025; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | /// 30 | public DriversLicenseData ParseData(string? data) 31 | { 32 | var licenseData = ParsingHelpers.BasicDriversLicenseParser( 33 | data, 34 | Country, 35 | out var splitUpData); 36 | licenseData.CustomerId = splitUpData["DAQ"]; 37 | licenseData.AuditInformation = splitUpData["DL_"]; 38 | licenseData.InventoryControl = splitUpData.ContainsKey("ANSI") 39 | ? splitUpData["ANSI"] 40 | : splitUpData["AAMVA"]; 41 | return licenseData; 42 | } 43 | } -------------------------------------------------------------------------------- /DLP.Core/README.md: -------------------------------------------------------------------------------- 1 | [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/joshuaquiz/DriversLicenseParser/blob/main/LICENSE) 2 | [![.NET](https://github.com/joshuaquiz/DriversLicenseParser/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/joshuaquiz/DriversLicenseParser/actions/workflows/dotnet.yml) 3 | 4 | # Drivers License Parser 5 | 6 | Drivers licenses in the USA/Canada are all over the map and there are some sugestions that states follow but not all of them. How do you handle these differences? You could write and maintain this on your own or use an API that can parse the data from the bar code. If you want to do the former then feel free to copy this code, it is offered as is. If you want to use an API you can see the blow documentation on how to do that. 7 | 8 | # More in-depth information 9 | 10 | For more information about formatting, data, questions, etc [visit the wiki](https://github.com/joshuaquiz/DriversLicenseParser/wiki) 11 | 12 | # Credits 13 | 14 | Credit to [@ksoftllc](https://github.com/ksoftllc) and his Swift library that I used to copy some of the parts that I did not have examples for - https://github.com/ksoftllc/license-parser 15 | 16 | Driving license icons created by [Freepik - Flaticon](https://www.flaticon.com/free-icons/driving-license) 17 | 18 | # Support 19 | If you want to support my work click here: [Sponsor joshuaquiz](https://github.com/sponsors/joshuaquiz) 20 | -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/EyeColor.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA Eye Colors:
5 | /// - Unknown: Unknown eye color
6 | /// - Black: Black eyes
7 | /// - Blue: Blue eyes
8 | /// - Brown: Brown eyes
9 | /// - Gray: Gray eyes
10 | /// - Green: Green eyes
11 | /// - Hazel: Hazel eyes
12 | /// - Maroon: Maroon eyes
13 | /// - Pink: Pink eyes
14 | /// - Dichromatic: Dichromatic eyes
15 | ///
16 | public enum EyeColor 17 | { 18 | /// 19 | /// Unknown eye color. 20 | /// 21 | Unknown, 22 | 23 | /// 24 | /// Black eye color. 25 | /// 26 | Black, 27 | 28 | /// 29 | /// Blue eye color. 30 | /// 31 | Blue, 32 | 33 | /// 34 | /// Brown eye color. 35 | /// 36 | Brown, 37 | 38 | /// 39 | /// Gray eye color. 40 | /// 41 | Gray, 42 | 43 | /// 44 | /// Green eye color. 45 | /// 46 | Green, 47 | 48 | /// 49 | /// Hazel eye color. 50 | /// 51 | Hazel, 52 | 53 | /// 54 | /// Maroon eye color. 55 | /// 56 | Maroon, 57 | 58 | /// 59 | /// Pink eye color. 60 | /// 61 | Pink, 62 | 63 | /// 64 | /// Dichromatic eye color. 65 | /// 66 | Dichromatic 67 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Oregon.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of Oregon. 10 | /// 11 | public sealed class Oregon : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "Oregon"; 15 | 16 | /// 17 | public string Abbreviation => "OR"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636029; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | private const string StreetAddressMarkerBackup = "DAL"; 30 | 31 | /// 32 | public DriversLicenseData ParseData(string? data) 33 | { 34 | var driversLicenseData = ParsingHelpers.BasicDriversLicenseParser( 35 | data, 36 | Country, 37 | out var splitUpData); 38 | if (driversLicenseData.LicenseVersion == LicenseVersion.Version1) 39 | { 40 | if (string.IsNullOrWhiteSpace(driversLicenseData.StreetAddress)) 41 | { 42 | driversLicenseData.StreetAddress = splitUpData.TryGetValue(StreetAddressMarkerBackup); 43 | } 44 | } 45 | 46 | return driversLicenseData; 47 | } 48 | } -------------------------------------------------------------------------------- /DLP.Lambda/aws-lambda-tools-defaults.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "Information" : [ 4 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", 5 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", 6 | "dotnet lambda help", 7 | "All the command line options for the Lambda command can be specified in this file." 8 | ], 9 | "configuration" : "Release", 10 | "package-type" : "Zip", 11 | "function-memory-size" : 256, 12 | "function-timeout" : 30, 13 | "image-command" : "DLP.Lambda::DLP.Lambda.Function::FunctionHandler", 14 | "docker-host-build-output-dir" : "./bin/Release/lambda-publish", 15 | "region" : "us-east-1", 16 | "profile" : "personal-account", 17 | "framework" : "net6.0", 18 | "function-name" : "DriversLicenseParser", 19 | "function-handler" : "DLP.Lambda::DLP.Lambda.Function::Post", 20 | "function-role" : "arn:aws:iam::525722201980:role/lambda_exec_DriversLicenseParser", 21 | "function-runtime" : "dotnet6", 22 | "function-architecture" : "arm64", 23 | "tracing-mode" : "PassThrough", 24 | "environment-variables" : "", 25 | "dockerfile" : "Dockerfile", 26 | "image-tag" : "", 27 | "function-description" : "" 28 | } -------------------------------------------------------------------------------- /DLP.Core/Interfaces/IParseableLicense.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Models; 2 | using DLP.Core.Models.Enums; 3 | 4 | namespace DLP.Core.Interfaces; 5 | 6 | /// 7 | /// Represents a entity with a parseable license. 8 | /// 9 | public interface IParseableLicense 10 | { 11 | /// 12 | /// The friendly name of the state, provence, or other locality that issued the license. 13 | /// 14 | public string FullName { get; } 15 | 16 | /// 17 | /// The abbreviation of the state, provence, or other locality that issued the license. 18 | /// 19 | public string Abbreviation { get; } 20 | 21 | /// 22 | /// The country that issued the license. 23 | /// 24 | public IssuingCountry Country { get; } 25 | 26 | /// 27 | /// Drivers License Issuer Identification Number. 28 | /// 29 | /// 30 | /// This list can be found (as of the time of this writing) at https://www.aamva.org/IIN-and-RID/ 31 | /// 32 | public int IssuerIdentificationNumber { get; } 33 | 34 | /// 35 | /// Is this data from this entity. 36 | /// 37 | /// The license data. 38 | /// bool 39 | public bool IsDataFromEntity(string? data); 40 | 41 | /// 42 | /// Parses the string into a . 43 | /// 44 | /// The license data. 45 | /// 46 | public DriversLicenseData ParseData(string? data); 47 | } -------------------------------------------------------------------------------- /DLP.Lambda/Function.cs: -------------------------------------------------------------------------------- 1 | using Amazon.Lambda.APIGatewayEvents; 2 | using Amazon.Lambda.Core; 3 | using Amazon.Lambda.Serialization.SystemTextJson; 4 | using DLP.Core.Helpers; 5 | using DLP.Core.Interfaces; 6 | using DLP.Lambda; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Newtonsoft.Json; 9 | using System.Net; 10 | using System.Text.Json.Serialization; 11 | 12 | // Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. 13 | [assembly: LambdaSerializer(typeof(SourceGeneratorLambdaJsonSerializer))] 14 | 15 | namespace DLP.Lambda; 16 | 17 | [JsonSerializable(typeof(APIGatewayHttpApiV2ProxyRequest))] 18 | [JsonSerializable(typeof(APIGatewayHttpApiV2ProxyResponse))] 19 | public partial class HttpApiJsonSerializerContext : JsonSerializerContext 20 | { 21 | } 22 | 23 | public sealed class Function 24 | { 25 | private readonly IServiceProvider _serviceProvider; 26 | 27 | public Function() 28 | { 29 | var serviceCollection = new ServiceCollection(); 30 | serviceCollection.AddDriversLicenseParsing(); 31 | _serviceProvider = serviceCollection.BuildServiceProvider(); 32 | } 33 | 34 | public APIGatewayHttpApiV2ProxyResponse Post( 35 | APIGatewayHttpApiV2ProxyRequest request, 36 | ILambdaContext context) => 37 | new() 38 | { 39 | StatusCode = (int)HttpStatusCode.OK, 40 | Body = JsonConvert.SerializeObject( 41 | _serviceProvider.GetRequiredService() 42 | .Parse( 43 | request.Body)), 44 | Headers = new Dictionary {{"Content-Type", "application/json"}} 45 | }; 46 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Washington.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | using DLP.Core.Parsers; 6 | 7 | namespace DLP.Core.ParseableLicenses; 8 | 9 | /// 10 | /// Represents a license from the US state of Washington. 11 | /// 12 | public sealed class Washington : IParseableLicense 13 | { 14 | /// 15 | public string FullName => "Washington"; 16 | 17 | /// 18 | public string Abbreviation => "WA"; 19 | 20 | /// 21 | public IssuingCountry Country => IssuingCountry.UnitedStates; 22 | 23 | /// 24 | public int IssuerIdentificationNumber => 636045; 25 | 26 | /// 27 | public bool IsDataFromEntity(string? data) => 28 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 29 | 30 | /// 31 | public DriversLicenseData ParseData(string? data) 32 | { 33 | var driversLicenseData = ParsingHelpers.BasicDriversLicenseParser( 34 | data, 35 | Country, 36 | out var splitUpData); 37 | if (driversLicenseData.LicenseVersion == LicenseVersion.Version3) 38 | { 39 | if (splitUpData.TryGetValue(Version3StandardParser.Version3StandardMarkers.FirstNameMarker, out var firstName)) 40 | { 41 | var nameParts = firstName?.Split(' '); 42 | if (nameParts?.Length == 2) 43 | { 44 | driversLicenseData.FirstName = nameParts[0]; 45 | driversLicenseData.MiddleName = nameParts[1]; 46 | } 47 | } 48 | } 49 | 50 | return driversLicenseData; 51 | } 52 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Wyoming.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | using System; 6 | 7 | namespace DLP.Core.ParseableLicenses; 8 | 9 | /// 10 | /// Represents a license from the US state of Wyoming. 11 | /// 12 | public sealed class Wyoming : IParseableLicense 13 | { 14 | /// 15 | public string FullName => "Wyoming"; 16 | 17 | /// 18 | public string Abbreviation => "WY"; 19 | 20 | /// 21 | public IssuingCountry Country => IssuingCountry.UnitedStates; 22 | 23 | /// 24 | public int IssuerIdentificationNumber => 636060; 25 | 26 | /// 27 | public bool IsDataFromEntity(string? data) => 28 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 29 | 30 | /// 31 | public DriversLicenseData ParseData(string? data) 32 | { 33 | var driversLicenseData = ParsingHelpers.BasicDriversLicenseParser( 34 | data, 35 | Country, 36 | out _); 37 | if (driversLicenseData.LicenseVersion == LicenseVersion.Version4) 38 | { 39 | if (driversLicenseData.FirstName?.Contains(' ') == true 40 | && string.IsNullOrWhiteSpace(driversLicenseData.MiddleName)) 41 | { 42 | var firstSpaceIndex = driversLicenseData.FirstName.IndexOf(' ', StringComparison.InvariantCultureIgnoreCase); 43 | driversLicenseData.MiddleName = driversLicenseData.FirstName[firstSpaceIndex..].Trim(); 44 | driversLicenseData.FirstName = driversLicenseData.FirstName.Remove(firstSpaceIndex); 45 | } 46 | } 47 | 48 | return driversLicenseData; 49 | } 50 | } -------------------------------------------------------------------------------- /DLP.Core/Models/Enums/NameSuffix.cs: -------------------------------------------------------------------------------- 1 | namespace DLP.Core.Models.Enums; 2 | 3 | /// 4 | /// AAMVA Name Suffixes:
5 | /// - Unknown: When the name suffix is unknown
6 | /// - Junior: Junior, Jr.
7 | /// - Senior: Senior, Sr.
8 | /// - First: First, I, 1st
9 | /// - Second: Second, II, 2nd
10 | /// - Third: Third, III, 3rd
11 | /// - Fourth: Fourth, IV, 4th
12 | /// - Fifth: Fifth, V, 5th
13 | /// - Sixth: Sixth, VI, 6th
14 | /// - Seventh: Seventh, VII, 7th
15 | /// - Eighth: Eighth, VIII, 8th
16 | /// - Ninth: Ninth, IX, 9th
17 | ///
18 | public enum NameSuffix 19 | { 20 | /// 21 | /// When the name suffix is unknown. 22 | /// 23 | Unknown, 24 | 25 | /// 26 | /// Junior, Jr. 27 | /// 28 | Junior, 29 | 30 | /// 31 | /// Senior, Sr. 32 | /// 33 | Senior, 34 | 35 | /// 36 | /// First, I, 1st. 37 | /// 38 | First, 39 | 40 | /// 41 | /// Second, II, 2nd. 42 | /// 43 | Second, 44 | 45 | /// 46 | /// Third, III, 3rd. 47 | /// 48 | Third, 49 | 50 | /// 51 | /// Fourth, IV, 4th. 52 | /// 53 | Fourth, 54 | 55 | /// 56 | /// Fifth, V, 5th. 57 | /// 58 | Fifth, 59 | 60 | /// 61 | /// Sixth, VI, 6th. 62 | /// 63 | Sixth, 64 | 65 | /// 66 | /// Seventh, VII, 7th. 67 | /// 68 | Seventh, 69 | 70 | /// 71 | /// Eighth, VIII, 8th. 72 | /// 73 | Eighth, 74 | 75 | /// 76 | /// Ninth, IX, 9th. 77 | /// 78 | Ninth 79 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/NorthCarolina.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | 6 | namespace DLP.Core.ParseableLicenses; 7 | 8 | /// 9 | /// Represents a license from the US state of North Carolina. 10 | /// 11 | public sealed class NorthCarolina : IParseableLicense 12 | { 13 | /// 14 | public string FullName => "North Carolina"; 15 | 16 | /// 17 | public string Abbreviation => "NC"; 18 | 19 | /// 20 | public IssuingCountry Country => IssuingCountry.UnitedStates; 21 | 22 | /// 23 | public int IssuerIdentificationNumber => 636004; 24 | 25 | /// 26 | public bool IsDataFromEntity(string? data) => 27 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 28 | 29 | private const string StreetAddressMarkerBackup = "DAL"; 30 | 31 | private const string CityMarkerBackup = "DAN"; 32 | 33 | private const string StateMarkerBackup = "DAO"; 34 | 35 | private const string PostalCodeMarkerBackup = "DAP"; 36 | 37 | private const string DocumentIdMarkerBackup = "DAQ"; 38 | 39 | private const string HeightMarkerBackup = "DAV"; 40 | 41 | /// 42 | public DriversLicenseData ParseData(string? data) 43 | { 44 | var driversLicenseData = ParsingHelpers.BasicDriversLicenseParser( 45 | data, 46 | Country, 47 | out var splitUpData); 48 | if (driversLicenseData.LicenseVersion == LicenseVersion.Version1) 49 | { 50 | driversLicenseData.StreetAddress ??= splitUpData.TryGetValue(StreetAddressMarkerBackup); 51 | driversLicenseData.City ??= splitUpData.TryGetValue(CityMarkerBackup); 52 | driversLicenseData.State ??= splitUpData.TryGetValue(StateMarkerBackup); 53 | driversLicenseData.PostalCode ??= splitUpData.TryGetValue(PostalCodeMarkerBackup); 54 | driversLicenseData.DocumentId ??= splitUpData.TryGetValue(DocumentIdMarkerBackup); 55 | driversLicenseData.Height ??= splitUpData.TryGetValue(HeightMarkerBackup).ParseHeightInInches(); 56 | } 57 | 58 | return driversLicenseData; 59 | } 60 | } -------------------------------------------------------------------------------- /DLP.Tests/Exceptions/LicenseFormatExceptionTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Exceptions; 2 | using DLP.Core.Helpers; 3 | using FluentAssertions; 4 | using FluentAssertions.Execution; 5 | using System; 6 | using Xunit; 7 | 8 | namespace DLP.Tests.Exceptions; 9 | 10 | public static class LicenseFormatExceptionTests 11 | { 12 | [Fact] 13 | public static void MessageIsCorrect() 14 | { 15 | // Arrange. 16 | var licenseFormatException = new LicenseFormatException(null); 17 | 18 | // Assert. 19 | using (new AssertionScope()) 20 | { 21 | Constants.ErrorMessages.LicenseFormatExceptionMessage 22 | .Should() 23 | .Be(licenseFormatException.Message); 24 | } 25 | } 26 | 27 | [Fact] 28 | public static void HelpLinkIsCorrect() 29 | { 30 | // Arrange. 31 | var licenseFormatException = new LicenseFormatException(null); 32 | 33 | // Assert. 34 | using (new AssertionScope()) 35 | { 36 | Constants.LicenseFormatExceptionHelpUrl.ToString() 37 | .Should() 38 | .Be(licenseFormatException.HelpLink); 39 | } 40 | } 41 | 42 | [Fact] 43 | public static void LicenseDataIsCorrect() 44 | { 45 | // Arrange. 46 | var licenseData = Guid.NewGuid().ToString(); 47 | var licenseFormatException = new LicenseFormatException(licenseData); 48 | 49 | // Assert. 50 | using (new AssertionScope()) 51 | { 52 | licenseFormatException.LicenseData 53 | .Should() 54 | .Be(licenseData); 55 | } 56 | } 57 | 58 | [Fact] 59 | public static void ToStringIsCorrect() 60 | { 61 | // Arrange. 62 | var licenseData = Guid.NewGuid().ToString(); 63 | var licenseFormatException = new LicenseFormatException(licenseData); 64 | 65 | // Act. 66 | var result = licenseFormatException.ToString(); 67 | 68 | // Assert. 69 | using (new AssertionScope()) 70 | { 71 | result 72 | .Should() 73 | .Be($"{Constants.ErrorMessages.LicenseFormatExceptionMessage}{Environment.NewLine}License Data: {licenseData}{Environment.NewLine}"); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /DLP.Core/DLP.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net9.0 4 | latest 5 | enable 6 | disable 7 | True 8 | true 9 | Joshua Galloway 10 | G3Software 11 | DriversLicenseParser 12 | Parses drivers licenses data scanned from barcode 13 | 14 | https://github.com/joshuaquiz/DriversLicenseParser 15 | GitHub 16 | DriversLicenseParser 17 | True 18 | https://github.com/joshuaquiz/DriversLicenseParser 19 | aamva drivers-licenses 20 | en-US 21 | 1.0.0 22 | README.md 23 | AGPL-3.0-or-later 24 | driving-license.ico 25 | 26 | 27 | DLP.Core\DLP.Core.xml 28 | true 29 | 30 | 31 | \DLP.Core\DLP.Core.xml 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | Always 40 | 41 | 42 | Always 43 | 44 | 45 | 46 | 47 | True 48 | \ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | True 58 | \ 59 | 60 | 61 | -------------------------------------------------------------------------------- /DriversLicenseParser.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32414.318 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DLP.Core", "DLP.Core\DLP.Core.csproj", "{CBAE789C-C8A4-4AE2-8FCE-C5628A7FE782}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DLP.Tests", "DLP.Tests\DLP.Tests.csproj", "{0E64B24A-2995-4DD6-B899-06075D67DB9E}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3029DD2F-16E7-4152-B0C9-2B7C208F8328}" 11 | ProjectSection(SolutionItems) = preProject 12 | .editorconfig = .editorconfig 13 | .gitignore = .gitignore 14 | LICENSE = LICENSE 15 | README.md = README.md 16 | SECURITY.md = SECURITY.md 17 | EndProjectSection 18 | EndProject 19 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{51B618FC-9FAE-45DA-868C-91210FC12941}" 20 | ProjectSection(SolutionItems) = preProject 21 | .github\workflows\dotnet.yml = .github\workflows\dotnet.yml 22 | EndProjectSection 23 | EndProject 24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DLP.Lambda", "DLP.Lambda\DLP.Lambda.csproj", "{452B8610-9F9A-4D42-962B-117D2C35F326}" 25 | EndProject 26 | Global 27 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 28 | Debug|Any CPU = Debug|Any CPU 29 | Release|Any CPU = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {CBAE789C-C8A4-4AE2-8FCE-C5628A7FE782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {CBAE789C-C8A4-4AE2-8FCE-C5628A7FE782}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {CBAE789C-C8A4-4AE2-8FCE-C5628A7FE782}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {CBAE789C-C8A4-4AE2-8FCE-C5628A7FE782}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {0E64B24A-2995-4DD6-B899-06075D67DB9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {0E64B24A-2995-4DD6-B899-06075D67DB9E}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {0E64B24A-2995-4DD6-B899-06075D67DB9E}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {0E64B24A-2995-4DD6-B899-06075D67DB9E}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {452B8610-9F9A-4D42-962B-117D2C35F326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {452B8610-9F9A-4D42-962B-117D2C35F326}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {452B8610-9F9A-4D42-962B-117D2C35F326}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {452B8610-9F9A-4D42-962B-117D2C35F326}.Release|Any CPU.Build.0 = Release|Any CPU 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(NestedProjects) = preSolution 49 | {51B618FC-9FAE-45DA-868C-91210FC12941} = {3029DD2F-16E7-4152-B0C9-2B7C208F8328} 50 | EndGlobalSection 51 | GlobalSection(ExtensibilityGlobals) = postSolution 52 | SolutionGuid = {A299BD35-B249-497C-B9E9-8FF3666410D7} 53 | EndGlobalSection 54 | EndGlobal 55 | -------------------------------------------------------------------------------- /DLP.Tests/DriversLicenseParserTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using DLP.Core; 4 | using DLP.Core.Exceptions; 5 | using DLP.Core.Helpers; 6 | using DLP.Core.Interfaces; 7 | using DLP.Core.Models; 8 | using FluentAssertions; 9 | using FluentAssertions.Execution; 10 | using Moq; 11 | using Xunit; 12 | 13 | namespace DLP.Tests; 14 | 15 | public static class DriversLicenseParserTests 16 | { 17 | [Theory] 18 | [InlineData(null)] 19 | [InlineData("")] 20 | [InlineData(" ")] 21 | public static void ThrowsArgumentNullExceptionIfNullDataProvided(string data) 22 | { 23 | // Arrange. 24 | var driversLicenseParser = new DriversLicenseParser(null); 25 | 26 | // Act. 27 | var act = () => driversLicenseParser.Parse(data); 28 | 29 | // Assert. 30 | using (new AssertionScope()) 31 | { 32 | act.Should() 33 | .Throw() 34 | .WithMessage("Value cannot be null. (Parameter 'data')"); 35 | } 36 | } 37 | 38 | [Fact] 39 | public static void ThrowsLicenseFormatExceptionIfNoProvidersFoundForData() 40 | { 41 | // Arrange. 42 | var data = Guid.NewGuid().ToString(); 43 | var driversLicenseParser = new DriversLicenseParser(null); 44 | 45 | // Act. 46 | var act = () => driversLicenseParser.Parse(data); 47 | 48 | // Assert. 49 | using (new AssertionScope()) 50 | { 51 | var exception = act.Should() 52 | .Throw() 53 | .WithMessage(Constants.ErrorMessages.LicenseFormatExceptionMessage) 54 | .And; 55 | exception.LicenseData.Should().Be(data); 56 | exception.HelpLink.Should().Be(Constants.LicenseFormatExceptionHelpUrl.ToString()); 57 | } 58 | } 59 | 60 | [Fact] 61 | public static void ParsesDataCorrectly() 62 | { 63 | // Arrange. 64 | var data = Guid.NewGuid().ToString(); 65 | var id = Guid.NewGuid().ToString(); 66 | var notTheParser = new Mock(MockBehavior.Strict); 67 | notTheParser 68 | .Setup(x => x.IsDataFromEntity(data)) 69 | .Returns(false); 70 | var theParser = new Mock(MockBehavior.Strict); 71 | theParser 72 | .Setup(x => x.IsDataFromEntity(data)) 73 | .Returns(true); 74 | theParser 75 | .Setup(x => x.ParseData(data)) 76 | .Returns( 77 | new DriversLicenseData 78 | { 79 | DocumentId = id 80 | }); 81 | var parsers = new List 82 | { 83 | notTheParser.Object, 84 | theParser.Object 85 | }; 86 | var driversLicenseParser = new DriversLicenseParser(parsers); 87 | 88 | // Act. 89 | var result = driversLicenseParser.Parse(data); 90 | 91 | // Assert. 92 | using (new AssertionScope()) 93 | { 94 | result.DocumentId.Should().Be(id); 95 | notTheParser.VerifyAll(); 96 | theParser.VerifyAll(); 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /DLP.Lambda/Readme.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Empty Docker Image Function Project 2 | 3 | This starter project consists of: 4 | * Function.cs - Class file containing a class with a single function handler method 5 | * Dockerfile - Used with the `docker build` command to build the docker image 6 | * aws-lambda-tools-defaults.json - default argument settings for use within Visual Studio and command line deployment tools for AWS 7 | 8 | You may also have a test project depending on the options selected. 9 | 10 | ## Packaging as a Docker image. 11 | 12 | This project is configured to package the Lambda function as a Docker image. The default configuration for the project and the Dockerfile is to build 13 | the .NET project on the host machine and then execute the `docker build` command which copies the .NET build artifacts from the host machine into 14 | the Docker image. 15 | 16 | The `--docker-host-build-output-dir` switch, which is set in the `aws-lambda-tools-defaults.json`, triggers the 17 | AWS .NET Lambda tooling to build the .NET project into the directory indicated by `--docker-host-build-output-dir`. The Dockerfile 18 | has a **COPY** command which copies the value from the directory pointed to by `--docker-host-build-output-dir` to the `/var/task` directory inside of the 19 | image. 20 | 21 | Alternatively the Docker file could be written to use [multi-stage](https://docs.docker.com/develop/develop-images/multistage-build/) builds and 22 | have the .NET project built inside the container. Below is an example of building the .NET project inside the image. 23 | 24 | ```dockerfile 25 | FROM public.ecr.aws/lambda/dotnet:6 AS base 26 | 27 | FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim as build 28 | WORKDIR /src 29 | COPY ["DLP.Lambda.csproj", "DLP.Lambda/"] 30 | RUN dotnet restore "DLP.Lambda/DLP.Lambda.csproj" 31 | 32 | WORKDIR "/src/DLP.Lambda" 33 | COPY . . 34 | RUN dotnet build "DLP.Lambda.csproj" --configuration Release --output /app/build 35 | 36 | FROM build AS publish 37 | RUN dotnet publish "DLP.Lambda.csproj" \ 38 | --configuration Release \ 39 | --runtime linux-x64 \ 40 | --self-contained false \ 41 | --output /app/publish \ 42 | -p:PublishReadyToRun=true 43 | 44 | FROM base AS final 45 | WORKDIR /var/task 46 | COPY --from=publish /app/publish . 47 | ``` 48 | 49 | When building the .NET project inside the image you must be sure to copy all of the class libraries the .NET Lambda project is depending on 50 | as well before the `dotnet build` step. The final published artifacts of the .NET project must be copied to the `/var/task` directory. 51 | The `--docker-host-build-output-dir` switch can also be removed from the `aws-lambda-tools-defaults.json` to avoid the 52 | .NET project from being built on the host machine before calling `docker build`. 53 | 54 | 55 | 56 | ## Here are some steps to follow from Visual Studio: 57 | 58 | To deploy your function to AWS Lambda, right click the project in Solution Explorer and select *Publish to AWS Lambda*. 59 | 60 | To view your deployed function open its Function View window by double-clicking the function name shown beneath the AWS Lambda node in the AWS Explorer tree. 61 | 62 | To perform testing against your deployed function use the Test Invoke tab in the opened Function View window. 63 | 64 | To configure event sources for your deployed function, for example to have your function invoked when an object is created in an Amazon S3 bucket, use the Event Sources tab in the opened Function View window. 65 | 66 | To update the runtime configuration of your deployed function use the Configuration tab in the opened Function View window. 67 | 68 | To view execution logs of invocations of your function use the Logs tab in the opened Function View window. 69 | 70 | ## Here are some steps to follow to get started from the command line: 71 | 72 | You can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. Lambda function packaged as a Docker image require version 5.0.0 or later. 73 | 74 | Install Amazon.Lambda.Tools Global Tools if not already installed. 75 | ``` 76 | dotnet tool install -g Amazon.Lambda.Tools 77 | ``` 78 | 79 | If already installed check if new version is available. 80 | ``` 81 | dotnet tool update -g Amazon.Lambda.Tools 82 | ``` 83 | 84 | Execute unit tests 85 | ``` 86 | cd "DLP.Lambda/test/DLP.Lambda.Tests" 87 | dotnet test 88 | ``` 89 | 90 | Deploy function to AWS Lambda 91 | ``` 92 | cd "DLP.Lambda/src/DLP.Lambda" 93 | dotnet lambda deploy-function 94 | ``` 95 | -------------------------------------------------------------------------------- /DLP.Core/Models/DriversLicenseData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DLP.Core.Models.Enums; 3 | 4 | namespace DLP.Core.Models; 5 | 6 | /// 7 | /// Represents data parsed from a drivers license. 8 | /// 9 | public sealed record DriversLicenseData 10 | { 11 | /// 12 | /// Customer First Name 13 | /// 14 | public string? FirstName { get; set; } 15 | 16 | /// 17 | /// Customer Last Name 18 | /// 19 | public string? LastName { get; set; } 20 | 21 | /// 22 | /// Customer Middle Name 23 | /// 24 | public string? MiddleName { get; set; } 25 | 26 | /// 27 | /// Document Expiration Date 28 | /// 29 | public DateTimeOffset? ExpirationDate { get; set; } 30 | 31 | /// 32 | /// Document Issue Date 33 | /// 34 | public DateTimeOffset? IssueDate { get; set; } 35 | 36 | /// 37 | /// Customer Date of Birth 38 | /// 39 | public DateTimeOffset? DateOfBirth { get; set; } 40 | 41 | /// 42 | /// Customer Gender 43 | /// 44 | public Gender Gender { get; set; } 45 | 46 | /// 47 | /// Customer Eye Color 48 | /// 49 | public EyeColor EyeColor { get; set; } 50 | 51 | /// 52 | /// Customer Hair Color 53 | /// 54 | public HairColor HairColor { get; set; } 55 | 56 | /// 57 | /// Customer Height (in inches) 58 | /// 59 | public decimal? Height { get; set; } 60 | 61 | /// 62 | /// Customer Street Address 63 | /// 64 | public string? StreetAddress { get; set; } 65 | 66 | /// 67 | /// Customer Street Address Line 2 68 | /// 69 | public string? SecondStreetAddress { get; set; } 70 | 71 | /// 72 | /// Customer City 73 | /// 74 | public string? City { get; set; } 75 | 76 | /// 77 | /// Customer State 78 | /// 79 | public string? State { get; set; } 80 | 81 | /// 82 | /// Customer Postal Code 83 | /// 84 | public string? PostalCode { get; set; } 85 | 86 | /// 87 | /// Unique Customer ID Number 88 | /// 89 | public string? CustomerId { get; set; } 90 | 91 | /// 92 | /// Unique Document ID Number 93 | /// 94 | public string? DocumentId { get; set; } 95 | 96 | /// 97 | /// Issuing Country 98 | /// 99 | public IssuingCountry IssuingCountry { get; set; } 100 | 101 | /// 102 | /// Was Middle Name truncated? 103 | /// 104 | public Truncation MiddleNameTruncated { get; set; } 105 | 106 | /// 107 | /// Was First Name truncated? 108 | /// 109 | public Truncation FirstNameTruncated { get; set; } 110 | 111 | /// 112 | /// Was Last Name truncated? 113 | /// 114 | public Truncation LastNameTruncated { get; set; } 115 | 116 | /// 117 | /// Country and municipality and/or state/province. 118 | /// 119 | public string? PlaceOfBirth { get; set; } 120 | 121 | /// 122 | /// A string of letters and/or numbers that identifies when, where, and by whom a driver license/ID card was made. 123 | /// 124 | public string? AuditInformation { get; set; } 125 | 126 | /// 127 | /// A string of letters and/or numbers that is affixed to the raw materials (card stock, laminate, etc.) used in producing driver licenses and ID cards. 128 | /// 129 | public string? InventoryControl { get; set; } 130 | 131 | /// 132 | /// Other Last Name by which cardholder is known. 133 | /// 134 | public string? LastNameAlias { get; set; } 135 | 136 | /// 137 | /// Other First Name by which the cardholder is known. 138 | /// 139 | public string? FirstNameAlias { get; set; } 140 | 141 | /// 142 | /// Other suffix by which cardholder is known. 143 | /// 144 | public string? SuffixAlias { get; set; } 145 | 146 | /// 147 | /// Name Suffix. 148 | /// 149 | public NameSuffix NameSuffix { get; set; } 150 | 151 | /// 152 | /// The version of license. 153 | /// 154 | public LicenseVersion LicenseVersion{ get; set; } 155 | } -------------------------------------------------------------------------------- /DLP.Core/Helpers/StartupExtensions.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Interfaces; 2 | using DLP.Core.ParseableLicenses; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace DLP.Core.Helpers; 6 | 7 | /// 8 | /// Startup extensions. 9 | /// 10 | public static class StartupExtensions 11 | { 12 | /// 13 | /// Adds and its dependencies to the tree. 14 | /// 15 | /// 16 | /// 17 | public static IServiceCollection AddDriversLicenseParsing(this IServiceCollection provider) => 18 | provider 19 | .AddSingleton() 20 | .AddSingleton() 21 | .AddSingleton() 22 | .AddSingleton() 23 | .AddSingleton() 24 | .AddSingleton() 25 | .AddSingleton() 26 | .AddSingleton() 27 | .AddSingleton() 28 | .AddSingleton() 29 | .AddSingleton() 30 | .AddSingleton() 31 | .AddSingleton() 32 | .AddSingleton() 33 | .AddSingleton() 34 | .AddSingleton() 35 | .AddSingleton() 36 | .AddSingleton() 37 | .AddSingleton() 38 | .AddSingleton() 39 | .AddSingleton() 40 | .AddSingleton() 41 | .AddSingleton() 42 | .AddSingleton() 43 | .AddSingleton() 44 | .AddSingleton() 45 | .AddSingleton() 46 | .AddSingleton() 47 | .AddSingleton() 48 | .AddSingleton() 49 | .AddSingleton() 50 | .AddSingleton() 51 | .AddSingleton() 52 | .AddSingleton() 53 | .AddSingleton() 54 | .AddSingleton() 55 | .AddSingleton() 56 | .AddSingleton() 57 | .AddSingleton() 58 | .AddSingleton() 59 | .AddSingleton() 60 | .AddSingleton() 61 | .AddSingleton() 62 | .AddSingleton() 63 | .AddSingleton() 64 | .AddSingleton() 65 | .AddSingleton() 66 | .AddSingleton() 67 | .AddSingleton() 68 | .AddSingleton() 69 | .AddSingleton() 70 | .AddSingleton() 71 | .AddSingleton() 72 | .AddSingleton() 73 | .AddSingleton() 74 | .AddSingleton() 75 | .AddSingleton() 76 | .AddSingleton() 77 | .AddSingleton() 78 | .AddSingleton() 79 | .AddSingleton() 80 | .AddSingleton() 81 | .AddSingleton() 82 | .AddSingleton() 83 | .AddSingleton() 84 | .AddSingleton() 85 | .AddSingleton() 86 | .AddSingleton() 87 | .AddSingleton() 88 | .AddSingleton() 89 | .AddSingleton() 90 | .AddSingleton(); 91 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version5StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | public static class Version5StandardParser 9 | { 10 | public static DriversLicenseData ParseDriversLicenseData( 11 | string? data, 12 | out IReadOnlyDictionary splitUpData) 13 | { 14 | splitUpData = ParsingHelpers.SplitLicenseString(data); 15 | return new DriversLicenseData 16 | { 17 | FirstName = splitUpData.TryGetValue(Version5StandardMarkers.FirstNameMarker), 18 | LastName = splitUpData.TryGetValue(Version5StandardMarkers.LastNameMarker), 19 | MiddleName = splitUpData.TryGetValue(Version5StandardMarkers.MiddleNameMarker), 20 | ExpirationDate = splitUpData.TryGetValue(Version5StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 21 | IssueDate = splitUpData.TryGetValue(Version5StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 22 | DateOfBirth = splitUpData.TryGetValue(Version5StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 23 | Gender = splitUpData.TryGetValue(Version5StandardMarkers.GenderMarker).ParseGender(), 24 | EyeColor = splitUpData.TryGetValue(Version5StandardMarkers.EyeColorMarker).ParseEyeColor(), 25 | Height = splitUpData.TryGetValue(Version5StandardMarkers.HeightMarker).ParseHeightInInches(), 26 | StreetAddress = splitUpData.TryGetValue(Version5StandardMarkers.StreetAddressMarker), 27 | City = splitUpData.TryGetValue(Version5StandardMarkers.CityMarker), 28 | State = splitUpData.TryGetValue(Version5StandardMarkers.StateMarker), 29 | PostalCode = splitUpData.TryGetValue(Version5StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 30 | CustomerId = splitUpData.TryGetValue(Version5StandardMarkers.CustomerIdMarker), 31 | DocumentId = splitUpData.TryGetValue(Version5StandardMarkers.DocumentIdMarker), 32 | IssuingCountry = splitUpData.TryGetValue(Version5StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 33 | MiddleNameTruncated = splitUpData.TryGetValue(Version5StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 34 | FirstNameTruncated = splitUpData.TryGetValue(Version5StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 35 | LastNameTruncated = splitUpData.TryGetValue(Version5StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 36 | SecondStreetAddress = splitUpData.TryGetValue(Version5StandardMarkers.SecondStreetAddressMarker), 37 | HairColor = splitUpData.TryGetValue(Version5StandardMarkers.HairColorMarker).ParseHairColor(), 38 | PlaceOfBirth = splitUpData.TryGetValue(Version5StandardMarkers.PlaceOfBirthMarker), 39 | AuditInformation = splitUpData.TryGetValue(Version5StandardMarkers.AuditInformationMarker), 40 | InventoryControl = splitUpData.TryGetValue(Version5StandardMarkers.InventoryControlMarker), 41 | LastNameAlias = splitUpData.TryGetValue(Version5StandardMarkers.LastNameAliasMarker), 42 | FirstNameAlias = splitUpData.TryGetValue(Version5StandardMarkers.FirstNameAliasMarker), 43 | SuffixAlias = splitUpData.TryGetValue(Version5StandardMarkers.SuffixAliasMarker), 44 | NameSuffix = splitUpData.TryGetValue(Version5StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 45 | LicenseVersion = LicenseVersion.Version5 46 | }; 47 | } 48 | 49 | public static class Version5StandardMarkers 50 | { 51 | public const string FirstNameMarker = "DAC"; 52 | public const string LastNameMarker = "DCS"; 53 | public const string MiddleNameMarker = "DAD"; 54 | public const string ExpirationDateMarker = "DBA"; 55 | public const string IssueDateMarker = "DBD"; 56 | public const string DateOfBirthMarker = "DBB"; 57 | public const string GenderMarker = "DBC"; 58 | public const string EyeColorMarker = "DAY"; 59 | public const string HeightMarker = "DAU"; 60 | public const string StreetAddressMarker = "DAG"; 61 | public const string CityMarker = "DAI"; 62 | public const string StateMarker = "DAJ"; 63 | public const string PostalCodeMarker = "DAK"; 64 | public const string CustomerIdMarker = "DAQ"; 65 | public const string DocumentIdMarker = "DCF"; 66 | public const string IssuingCountryMarker = "DCG"; 67 | public const string MiddleNameTruncatedMarker = "DDG"; 68 | public const string FirstNameTruncatedMarker = "DDF"; 69 | public const string LastNameTruncatedMarker = "DDE"; 70 | public const string SecondStreetAddressMarker = "DAH"; 71 | public const string HairColorMarker = "DAZ"; 72 | public const string PlaceOfBirthMarker = "DCI"; 73 | public const string AuditInformationMarker = "DCJ"; 74 | public const string InventoryControlMarker = "DCK"; 75 | public const string LastNameAliasMarker = "DBN"; 76 | public const string FirstNameAliasMarker = "DBG"; 77 | public const string SuffixAliasMarker = "DBS"; 78 | public const string NameSuffixMarker = "DCU"; 79 | } 80 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version6StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | public static class Version6StandardParser 9 | { 10 | public static DriversLicenseData ParseDriversLicenseData( 11 | string? data, 12 | out IReadOnlyDictionary splitUpData) 13 | { 14 | splitUpData = ParsingHelpers.SplitLicenseString(data); 15 | return new DriversLicenseData 16 | { 17 | FirstName = splitUpData.TryGetValue(Version6StandardMarkers.FirstNameMarker), 18 | LastName = splitUpData.TryGetValue(Version6StandardMarkers.LastNameMarker), 19 | MiddleName = splitUpData.TryGetValue(Version6StandardMarkers.MiddleNameMarker), 20 | ExpirationDate = splitUpData.TryGetValue(Version6StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 21 | IssueDate = splitUpData.TryGetValue(Version6StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 22 | DateOfBirth = splitUpData.TryGetValue(Version6StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 23 | Gender = splitUpData.TryGetValue(Version6StandardMarkers.GenderMarker).ParseGender(), 24 | EyeColor = splitUpData.TryGetValue(Version6StandardMarkers.EyeColorMarker).ParseEyeColor(), 25 | Height = splitUpData.TryGetValue(Version6StandardMarkers.HeightMarker).ParseHeightInInches(), 26 | StreetAddress = splitUpData.TryGetValue(Version6StandardMarkers.StreetAddressMarker), 27 | City = splitUpData.TryGetValue(Version6StandardMarkers.CityMarker), 28 | State = splitUpData.TryGetValue(Version6StandardMarkers.StateMarker), 29 | PostalCode = splitUpData.TryGetValue(Version6StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 30 | CustomerId = splitUpData.TryGetValue(Version6StandardMarkers.CustomerIdMarker), 31 | DocumentId = splitUpData.TryGetValue(Version6StandardMarkers.DocumentIdMarker), 32 | IssuingCountry = splitUpData.TryGetValue(Version6StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 33 | MiddleNameTruncated = splitUpData.TryGetValue(Version6StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 34 | FirstNameTruncated = splitUpData.TryGetValue(Version6StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 35 | LastNameTruncated = splitUpData.TryGetValue(Version6StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 36 | SecondStreetAddress = splitUpData.TryGetValue(Version6StandardMarkers.SecondStreetAddressMarker), 37 | HairColor = splitUpData.TryGetValue(Version6StandardMarkers.HairColorMarker).ParseHairColor(), 38 | PlaceOfBirth = splitUpData.TryGetValue(Version6StandardMarkers.PlaceOfBirthMarker), 39 | AuditInformation = splitUpData.TryGetValue(Version6StandardMarkers.AuditInformationMarker), 40 | InventoryControl = splitUpData.TryGetValue(Version6StandardMarkers.InventoryControlMarker), 41 | LastNameAlias = splitUpData.TryGetValue(Version6StandardMarkers.LastNameAliasMarker), 42 | FirstNameAlias = splitUpData.TryGetValue(Version6StandardMarkers.FirstNameAliasMarker), 43 | SuffixAlias = splitUpData.TryGetValue(Version6StandardMarkers.SuffixAliasMarker), 44 | NameSuffix = splitUpData.TryGetValue(Version6StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 45 | LicenseVersion = LicenseVersion.Version6 46 | }; 47 | } 48 | 49 | public static class Version6StandardMarkers 50 | { 51 | public const string FirstNameMarker = "DAC"; 52 | public const string LastNameMarker = "DCS"; 53 | public const string MiddleNameMarker = "DAD"; 54 | public const string ExpirationDateMarker = "DBA"; 55 | public const string IssueDateMarker = "DBD"; 56 | public const string DateOfBirthMarker = "DBB"; 57 | public const string GenderMarker = "DBC"; 58 | public const string EyeColorMarker = "DAY"; 59 | public const string HeightMarker = "DAU"; 60 | public const string StreetAddressMarker = "DAG"; 61 | public const string CityMarker = "DAI"; 62 | public const string StateMarker = "DAJ"; 63 | public const string PostalCodeMarker = "DAK"; 64 | public const string CustomerIdMarker = "DAQ"; 65 | public const string DocumentIdMarker = "DCF"; 66 | public const string IssuingCountryMarker = "DCG"; 67 | public const string MiddleNameTruncatedMarker = "DDG"; 68 | public const string FirstNameTruncatedMarker = "DDF"; 69 | public const string LastNameTruncatedMarker = "DDE"; 70 | public const string SecondStreetAddressMarker = "DAH"; 71 | public const string HairColorMarker = "DAZ"; 72 | public const string PlaceOfBirthMarker = "DCI"; 73 | public const string AuditInformationMarker = "DCJ"; 74 | public const string InventoryControlMarker = "DCK"; 75 | public const string LastNameAliasMarker = "DBN"; 76 | public const string FirstNameAliasMarker = "DBG"; 77 | public const string SuffixAliasMarker = "DBS"; 78 | public const string NameSuffixMarker = "DCU"; 79 | } 80 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version7StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | public static class Version7StandardParser 9 | { 10 | public static DriversLicenseData ParseDriversLicenseData( 11 | string? data, 12 | out IReadOnlyDictionary splitUpData) 13 | { 14 | splitUpData = ParsingHelpers.SplitLicenseString(data); 15 | return new DriversLicenseData 16 | { 17 | FirstName = splitUpData.TryGetValue(Version7StandardMarkers.FirstNameMarker), 18 | LastName = splitUpData.TryGetValue(Version7StandardMarkers.LastNameMarker), 19 | MiddleName = splitUpData.TryGetValue(Version7StandardMarkers.MiddleNameMarker), 20 | ExpirationDate = splitUpData.TryGetValue(Version7StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 21 | IssueDate = splitUpData.TryGetValue(Version7StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 22 | DateOfBirth = splitUpData.TryGetValue(Version7StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 23 | Gender = splitUpData.TryGetValue(Version7StandardMarkers.GenderMarker).ParseGender(), 24 | EyeColor = splitUpData.TryGetValue(Version7StandardMarkers.EyeColorMarker).ParseEyeColor(), 25 | Height = splitUpData.TryGetValue(Version7StandardMarkers.HeightMarker).ParseHeightInInches(), 26 | StreetAddress = splitUpData.TryGetValue(Version7StandardMarkers.StreetAddressMarker), 27 | City = splitUpData.TryGetValue(Version7StandardMarkers.CityMarker), 28 | State = splitUpData.TryGetValue(Version7StandardMarkers.StateMarker), 29 | PostalCode = splitUpData.TryGetValue(Version7StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 30 | CustomerId = splitUpData.TryGetValue(Version7StandardMarkers.CustomerIdMarker), 31 | DocumentId = splitUpData.TryGetValue(Version7StandardMarkers.DocumentIdMarker), 32 | IssuingCountry = splitUpData.TryGetValue(Version7StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 33 | MiddleNameTruncated = splitUpData.TryGetValue(Version7StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 34 | FirstNameTruncated = splitUpData.TryGetValue(Version7StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 35 | LastNameTruncated = splitUpData.TryGetValue(Version7StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 36 | SecondStreetAddress = splitUpData.TryGetValue(Version7StandardMarkers.SecondStreetAddressMarker), 37 | HairColor = splitUpData.TryGetValue(Version7StandardMarkers.HairColorMarker).ParseHairColor(), 38 | PlaceOfBirth = splitUpData.TryGetValue(Version7StandardMarkers.PlaceOfBirthMarker), 39 | AuditInformation = splitUpData.TryGetValue(Version7StandardMarkers.AuditInformationMarker), 40 | InventoryControl = splitUpData.TryGetValue(Version7StandardMarkers.InventoryControlMarker), 41 | LastNameAlias = splitUpData.TryGetValue(Version7StandardMarkers.LastNameAliasMarker), 42 | FirstNameAlias = splitUpData.TryGetValue(Version7StandardMarkers.FirstNameAliasMarker), 43 | SuffixAlias = splitUpData.TryGetValue(Version7StandardMarkers.SuffixAliasMarker), 44 | NameSuffix = splitUpData.TryGetValue(Version7StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 45 | LicenseVersion = LicenseVersion.Version7 46 | }; 47 | } 48 | 49 | public static class Version7StandardMarkers 50 | { 51 | public const string FirstNameMarker = "DAC"; 52 | public const string LastNameMarker = "DCS"; 53 | public const string MiddleNameMarker = "DAD"; 54 | public const string ExpirationDateMarker = "DBA"; 55 | public const string IssueDateMarker = "DBD"; 56 | public const string DateOfBirthMarker = "DBB"; 57 | public const string GenderMarker = "DBC"; 58 | public const string EyeColorMarker = "DAY"; 59 | public const string HeightMarker = "DAU"; 60 | public const string StreetAddressMarker = "DAG"; 61 | public const string CityMarker = "DAI"; 62 | public const string StateMarker = "DAJ"; 63 | public const string PostalCodeMarker = "DAK"; 64 | public const string CustomerIdMarker = "DAQ"; 65 | public const string DocumentIdMarker = "DCF"; 66 | public const string IssuingCountryMarker = "DCG"; 67 | public const string MiddleNameTruncatedMarker = "DDG"; 68 | public const string FirstNameTruncatedMarker = "DDF"; 69 | public const string LastNameTruncatedMarker = "DDE"; 70 | public const string SecondStreetAddressMarker = "DAH"; 71 | public const string HairColorMarker = "DAZ"; 72 | public const string PlaceOfBirthMarker = "DCI"; 73 | public const string AuditInformationMarker = "DCJ"; 74 | public const string InventoryControlMarker = "DCK"; 75 | public const string LastNameAliasMarker = "DBN"; 76 | public const string FirstNameAliasMarker = "DBG"; 77 | public const string SuffixAliasMarker = "DBS"; 78 | public const string NameSuffixMarker = "DCU"; 79 | } 80 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version8StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | public static class Version8StandardParser 9 | { 10 | public static DriversLicenseData ParseDriversLicenseData( 11 | string? data, 12 | out IReadOnlyDictionary splitUpData) 13 | { 14 | splitUpData = ParsingHelpers.SplitLicenseString(data); 15 | return new DriversLicenseData 16 | { 17 | FirstName = splitUpData.TryGetValue(Version8StandardMarkers.FirstNameMarker), 18 | LastName = splitUpData.TryGetValue(Version8StandardMarkers.LastNameMarker), 19 | MiddleName = splitUpData.TryGetValue(Version8StandardMarkers.MiddleNameMarker), 20 | ExpirationDate = splitUpData.TryGetValue(Version8StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 21 | IssueDate = splitUpData.TryGetValue(Version8StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 22 | DateOfBirth = splitUpData.TryGetValue(Version8StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 23 | Gender = splitUpData.TryGetValue(Version8StandardMarkers.GenderMarker).ParseGender(), 24 | EyeColor = splitUpData.TryGetValue(Version8StandardMarkers.EyeColorMarker).ParseEyeColor(), 25 | Height = splitUpData.TryGetValue(Version8StandardMarkers.HeightMarker).ParseHeightInInches(), 26 | StreetAddress = splitUpData.TryGetValue(Version8StandardMarkers.StreetAddressMarker), 27 | City = splitUpData.TryGetValue(Version8StandardMarkers.CityMarker), 28 | State = splitUpData.TryGetValue(Version8StandardMarkers.StateMarker), 29 | PostalCode = splitUpData.TryGetValue(Version8StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 30 | CustomerId = splitUpData.TryGetValue(Version8StandardMarkers.CustomerIdMarker), 31 | DocumentId = splitUpData.TryGetValue(Version8StandardMarkers.DocumentIdMarker), 32 | IssuingCountry = splitUpData.TryGetValue(Version8StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 33 | MiddleNameTruncated = splitUpData.TryGetValue(Version8StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 34 | FirstNameTruncated = splitUpData.TryGetValue(Version8StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 35 | LastNameTruncated = splitUpData.TryGetValue(Version8StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 36 | SecondStreetAddress = splitUpData.TryGetValue(Version8StandardMarkers.SecondStreetAddressMarker), 37 | HairColor = splitUpData.TryGetValue(Version8StandardMarkers.HairColorMarker).ParseHairColor(), 38 | PlaceOfBirth = splitUpData.TryGetValue(Version8StandardMarkers.PlaceOfBirthMarker), 39 | AuditInformation = splitUpData.TryGetValue(Version8StandardMarkers.AuditInformationMarker), 40 | InventoryControl = splitUpData.TryGetValue(Version8StandardMarkers.InventoryControlMarker), 41 | LastNameAlias = splitUpData.TryGetValue(Version8StandardMarkers.LastNameAliasMarker), 42 | FirstNameAlias = splitUpData.TryGetValue(Version8StandardMarkers.FirstNameAliasMarker), 43 | SuffixAlias = splitUpData.TryGetValue(Version8StandardMarkers.SuffixAliasMarker), 44 | NameSuffix = splitUpData.TryGetValue(Version8StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 45 | LicenseVersion = LicenseVersion.Version8 46 | }; 47 | } 48 | 49 | public static class Version8StandardMarkers 50 | { 51 | public const string FirstNameMarker = "DAC"; 52 | public const string LastNameMarker = "DCS"; 53 | public const string MiddleNameMarker = "DAD"; 54 | public const string ExpirationDateMarker = "DBA"; 55 | public const string IssueDateMarker = "DBD"; 56 | public const string DateOfBirthMarker = "DBB"; 57 | public const string GenderMarker = "DBC"; 58 | public const string EyeColorMarker = "DAY"; 59 | public const string HeightMarker = "DAU"; 60 | public const string StreetAddressMarker = "DAG"; 61 | public const string CityMarker = "DAI"; 62 | public const string StateMarker = "DAJ"; 63 | public const string PostalCodeMarker = "DAK"; 64 | public const string CustomerIdMarker = "DAQ"; 65 | public const string DocumentIdMarker = "DCF"; 66 | public const string IssuingCountryMarker = "DCG"; 67 | public const string MiddleNameTruncatedMarker = "DDG"; 68 | public const string FirstNameTruncatedMarker = "DDF"; 69 | public const string LastNameTruncatedMarker = "DDE"; 70 | public const string SecondStreetAddressMarker = "DAH"; 71 | public const string HairColorMarker = "DAZ"; 72 | public const string PlaceOfBirthMarker = "DCI"; 73 | public const string AuditInformationMarker = "DCJ"; 74 | public const string InventoryControlMarker = "DCK"; 75 | public const string LastNameAliasMarker = "DBN"; 76 | public const string FirstNameAliasMarker = "DBG"; 77 | public const string SuffixAliasMarker = "DBS"; 78 | public const string NameSuffixMarker = "DCU"; 79 | } 80 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version9StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | public static class Version9StandardParser 9 | { 10 | public static DriversLicenseData ParseDriversLicenseData( 11 | string? data, 12 | out IReadOnlyDictionary splitUpData) 13 | { 14 | splitUpData = ParsingHelpers.SplitLicenseString(data); 15 | return new DriversLicenseData 16 | { 17 | FirstName = splitUpData.TryGetValue(Version9StandardMarkers.FirstNameMarker), 18 | LastName = splitUpData.TryGetValue(Version9StandardMarkers.LastNameMarker), 19 | MiddleName = splitUpData.TryGetValue(Version9StandardMarkers.MiddleNameMarker), 20 | ExpirationDate = splitUpData.TryGetValue(Version9StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 21 | IssueDate = splitUpData.TryGetValue(Version9StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 22 | DateOfBirth = splitUpData.TryGetValue(Version9StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 23 | Gender = splitUpData.TryGetValue(Version9StandardMarkers.GenderMarker).ParseGender(), 24 | EyeColor = splitUpData.TryGetValue(Version9StandardMarkers.EyeColorMarker).ParseEyeColor(), 25 | Height = splitUpData.TryGetValue(Version9StandardMarkers.HeightMarker).ParseHeightInInches(), 26 | StreetAddress = splitUpData.TryGetValue(Version9StandardMarkers.StreetAddressMarker), 27 | City = splitUpData.TryGetValue(Version9StandardMarkers.CityMarker), 28 | State = splitUpData.TryGetValue(Version9StandardMarkers.StateMarker), 29 | PostalCode = splitUpData.TryGetValue(Version9StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 30 | CustomerId = splitUpData.TryGetValue(Version9StandardMarkers.CustomerIdMarker), 31 | DocumentId = splitUpData.TryGetValue(Version9StandardMarkers.DocumentIdMarker), 32 | IssuingCountry = splitUpData.TryGetValue(Version9StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 33 | MiddleNameTruncated = splitUpData.TryGetValue(Version9StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 34 | FirstNameTruncated = splitUpData.TryGetValue(Version9StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 35 | LastNameTruncated = splitUpData.TryGetValue(Version9StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 36 | SecondStreetAddress = splitUpData.TryGetValue(Version9StandardMarkers.SecondStreetAddressMarker), 37 | HairColor = splitUpData.TryGetValue(Version9StandardMarkers.HairColorMarker).ParseHairColor(), 38 | PlaceOfBirth = splitUpData.TryGetValue(Version9StandardMarkers.PlaceOfBirthMarker), 39 | AuditInformation = splitUpData.TryGetValue(Version9StandardMarkers.AuditInformationMarker), 40 | InventoryControl = splitUpData.TryGetValue(Version9StandardMarkers.InventoryControlMarker), 41 | LastNameAlias = splitUpData.TryGetValue(Version9StandardMarkers.LastNameAliasMarker), 42 | FirstNameAlias = splitUpData.TryGetValue(Version9StandardMarkers.FirstNameAliasMarker), 43 | SuffixAlias = splitUpData.TryGetValue(Version9StandardMarkers.SuffixAliasMarker), 44 | NameSuffix = splitUpData.TryGetValue(Version9StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 45 | LicenseVersion = LicenseVersion.Version9 46 | }; 47 | } 48 | 49 | public static class Version9StandardMarkers 50 | { 51 | public const string FirstNameMarker = "DAC"; 52 | public const string LastNameMarker = "DCS"; 53 | public const string MiddleNameMarker = "DAD"; 54 | public const string ExpirationDateMarker = "DBA"; 55 | public const string IssueDateMarker = "DBD"; 56 | public const string DateOfBirthMarker = "DBB"; 57 | public const string GenderMarker = "DBC"; 58 | public const string EyeColorMarker = "DAY"; 59 | public const string HeightMarker = "DAU"; 60 | public const string StreetAddressMarker = "DAG"; 61 | public const string CityMarker = "DAI"; 62 | public const string StateMarker = "DAJ"; 63 | public const string PostalCodeMarker = "DAK"; 64 | public const string CustomerIdMarker = "DAQ"; 65 | public const string DocumentIdMarker = "DCF"; 66 | public const string IssuingCountryMarker = "DCG"; 67 | public const string MiddleNameTruncatedMarker = "DDG"; 68 | public const string FirstNameTruncatedMarker = "DDF"; 69 | public const string LastNameTruncatedMarker = "DDE"; 70 | public const string SecondStreetAddressMarker = "DAH"; 71 | public const string HairColorMarker = "DAZ"; 72 | public const string PlaceOfBirthMarker = "DCI"; 73 | public const string AuditInformationMarker = "DCJ"; 74 | public const string InventoryControlMarker = "DCK"; 75 | public const string LastNameAliasMarker = "DBN"; 76 | public const string FirstNameAliasMarker = "DBG"; 77 | public const string SuffixAliasMarker = "DBS"; 78 | public const string NameSuffixMarker = "DCU"; 79 | } 80 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version4StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | 6 | namespace DLP.Core.Parsers; 7 | 8 | /// 9 | /// Represents an AAMVA Version 4 license. 10 | /// 11 | public static class Version4StandardParser 12 | { 13 | /// 14 | /// Parses an AAMVA Version 4 license. 15 | /// 16 | /// The incoming raw data. 17 | /// The raw data split per this versions rules. 18 | /// 19 | public static DriversLicenseData ParseDriversLicenseData( 20 | string? data, 21 | out IReadOnlyDictionary splitUpData) 22 | { 23 | splitUpData = ParsingHelpers.SplitLicenseString(data); 24 | return new DriversLicenseData 25 | { 26 | FirstName = splitUpData.TryGetValue(Version4StandardMarkers.FirstNameMarker), 27 | LastName = splitUpData.TryGetValue(Version4StandardMarkers.LastNameMarker), 28 | MiddleName = splitUpData.TryGetValue(Version4StandardMarkers.MiddleNameMarker), 29 | ExpirationDate = splitUpData.TryGetValue(Version4StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 30 | IssueDate = splitUpData.TryGetValue(Version4StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 31 | DateOfBirth = splitUpData.TryGetValue(Version4StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 32 | Gender = splitUpData.TryGetValue(Version4StandardMarkers.GenderMarker).ParseGender(), 33 | EyeColor = splitUpData.TryGetValue(Version4StandardMarkers.EyeColorMarker).ParseEyeColor(), 34 | Height = splitUpData.TryGetValue(Version4StandardMarkers.HeightMarker).ParseHeightInInches(), 35 | StreetAddress = splitUpData.TryGetValue(Version4StandardMarkers.StreetAddressMarker), 36 | City = splitUpData.TryGetValue(Version4StandardMarkers.CityMarker), 37 | State = splitUpData.TryGetValue(Version4StandardMarkers.StateMarker), 38 | PostalCode = splitUpData.TryGetValue(Version4StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 39 | CustomerId = splitUpData.TryGetValue(Version4StandardMarkers.CustomerIdMarker), 40 | DocumentId = splitUpData.TryGetValue(Version4StandardMarkers.DocumentIdMarker), 41 | IssuingCountry = splitUpData.TryGetValue(Version4StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 42 | MiddleNameTruncated = splitUpData.TryGetValue(Version4StandardMarkers.MiddleNameTruncatedMarker).ParseTruncation(), 43 | FirstNameTruncated = splitUpData.TryGetValue(Version4StandardMarkers.FirstNameTruncatedMarker).ParseTruncation(), 44 | LastNameTruncated = splitUpData.TryGetValue(Version4StandardMarkers.LastNameTruncatedMarker).ParseTruncation(), 45 | SecondStreetAddress = splitUpData.TryGetValue(Version4StandardMarkers.SecondStreetAddressMarker), 46 | HairColor = splitUpData.TryGetValue(Version4StandardMarkers.HairColorMarker).ParseHairColor(), 47 | PlaceOfBirth = splitUpData.TryGetValue(Version4StandardMarkers.PlaceOfBirthMarker), 48 | AuditInformation = splitUpData.TryGetValue(Version4StandardMarkers.AuditInformationMarker), 49 | InventoryControl = splitUpData.TryGetValue(Version4StandardMarkers.InventoryControlMarker), 50 | LastNameAlias = splitUpData.TryGetValue(Version4StandardMarkers.LastNameAliasMarker), 51 | FirstNameAlias = splitUpData.TryGetValue(Version4StandardMarkers.FirstNameAliasMarker), 52 | SuffixAlias = splitUpData.TryGetValue(Version4StandardMarkers.SuffixAliasMarker), 53 | NameSuffix = splitUpData.TryGetValue(Version4StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 54 | LicenseVersion = LicenseVersion.Version4 55 | }; 56 | } 57 | 58 | /// 59 | /// AAMVA Version 4 license data codes 60 | /// 61 | /// 62 | /// These codes are used to mark where in the text data a certain field starts. 63 | /// 64 | public static class Version4StandardMarkers 65 | { 66 | public const string FirstNameMarker = "DAC"; 67 | public const string LastNameMarker = "DCS"; 68 | public const string MiddleNameMarker = "DAD"; 69 | public const string ExpirationDateMarker = "DBA"; 70 | public const string IssueDateMarker = "DBD"; 71 | public const string DateOfBirthMarker = "DBB"; 72 | public const string GenderMarker = "DBC"; 73 | public const string EyeColorMarker = "DAY"; 74 | public const string HeightMarker = "DAU"; 75 | public const string StreetAddressMarker = "DAG"; 76 | public const string CityMarker = "DAI"; 77 | public const string StateMarker = "DAJ"; 78 | public const string PostalCodeMarker = "DAK"; 79 | public const string CustomerIdMarker = "DAQ"; 80 | public const string DocumentIdMarker = "DCF"; 81 | public const string IssuingCountryMarker = "DCG"; 82 | public const string MiddleNameTruncatedMarker = "DDG"; 83 | public const string FirstNameTruncatedMarker = "DDF"; 84 | public const string LastNameTruncatedMarker = "DDE"; 85 | public const string SecondStreetAddressMarker = "DAH"; 86 | public const string HairColorMarker = "DAZ"; 87 | public const string PlaceOfBirthMarker = "DCI"; 88 | public const string AuditInformationMarker = "DCJ"; 89 | public const string InventoryControlMarker = "DCK"; 90 | public const string LastNameAliasMarker = "DBN"; 91 | public const string FirstNameAliasMarker = "DBG"; 92 | public const string SuffixAliasMarker = "DBS"; 93 | public const string NameSuffixMarker = "DCU"; 94 | } 95 | } -------------------------------------------------------------------------------- /DLP.Core/ParseableLicenses/Ohio.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Interfaces; 3 | using DLP.Core.Models; 4 | using DLP.Core.Models.Enums; 5 | using System; 6 | using System.Globalization; 7 | using System.Linq; 8 | 9 | namespace DLP.Core.ParseableLicenses; 10 | 11 | /// 12 | /// Represents a license from the US state of Ohio. 13 | /// 14 | public sealed class Ohio : IParseableLicense 15 | { 16 | /// 17 | public string FullName => "Ohio"; 18 | 19 | /// 20 | public string Abbreviation => "OH"; 21 | 22 | /// 23 | public IssuingCountry Country => IssuingCountry.UnitedStates; 24 | 25 | /// 26 | public int IssuerIdentificationNumber => 636023; 27 | 28 | /// 29 | public bool IsDataFromEntity(string? data) => 30 | data?.Contains(IssuerIdentificationNumber.ToString()) == true; 31 | 32 | /// 33 | public DriversLicenseData ParseData(string? data) => 34 | data?.Contains('^') == true 35 | ? ParseFlatOhioLicense(data) 36 | : ParsingHelpers.BasicDriversLicenseParser(data, Country, out _); 37 | 38 | private DriversLicenseData ParseFlatOhioLicense(string? data) 39 | { 40 | var license = new DriversLicenseData 41 | { 42 | State = Abbreviation, 43 | IssuingCountry = Country, 44 | LicenseVersion = LicenseVersion.UnknownVersion 45 | }; 46 | data = data.RemoveFirstOccurrence(license.State); 47 | var dataParts = data?.Split('^'); 48 | license.City = dataParts?.FirstOrDefault(); 49 | var namePart = dataParts?.ElementAtOrDefault(1) ?? string.Empty; 50 | var nameParts = namePart.Split('$', StringSplitOptions.RemoveEmptyEntries); 51 | switch (nameParts.Length) 52 | { 53 | case 1: 54 | license.LastName = nameParts[0]; 55 | break; 56 | case 2: 57 | license.LastName = nameParts[0]; 58 | license.FirstName = nameParts[1]; 59 | break; 60 | case 3: 61 | license.LastName = nameParts[0]; 62 | license.FirstName = nameParts[1]; 63 | license.MiddleName = nameParts[2]; 64 | break; 65 | default: 66 | license.LastName = namePart; 67 | break; 68 | } 69 | 70 | string? documentIdAndOtherData; 71 | if (dataParts?.Length == 4) 72 | { 73 | license.StreetAddress = dataParts.ElementAtOrDefault(2); 74 | documentIdAndOtherData = dataParts.ElementAtOrDefault(3) ?? string.Empty; 75 | } 76 | else 77 | { 78 | var dataText = dataParts?.ElementAtOrDefault(2); 79 | var rawStreetAddress = dataText?[ 80 | ..dataText.IndexOf( 81 | IssuerIdentificationNumber.ToString(), 82 | StringComparison.InvariantCultureIgnoreCase)]; 83 | license.StreetAddress = rawStreetAddress?.Trim(); 84 | documentIdAndOtherData = dataText.RemoveFirstOccurrence(rawStreetAddress); 85 | } 86 | 87 | var documentIdAndOtherDataParts = documentIdAndOtherData?.Split('='); 88 | license.InventoryControl = documentIdAndOtherDataParts?.FirstOrDefault(); 89 | license.CustomerId = documentIdAndOtherDataParts 90 | ?.FirstOrDefault() 91 | ?.RemoveFirstOccurrence(IssuerIdentificationNumber.ToString()); 92 | var remainingData = documentIdAndOtherDataParts?.ElementAtOrDefault(1); 93 | var startIndex = 0; 94 | license.ExpirationDate = DateTimeOffset.ParseExact(remainingData?.SubstringSafe(startIndex, 4) ?? string.Empty, "yyMM", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); 95 | startIndex += 4; 96 | license.DateOfBirth = DateTimeOffset.ParseExact(remainingData?.SubstringSafe(startIndex, 8) ?? string.Empty, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); 97 | startIndex += 8; 98 | var unknownFieldOne = remainingData?.SubstringSafe(startIndex, 2); 99 | startIndex += 2; 100 | var remainingDataParts = remainingData?[startIndex..]?.Split(' ', StringSplitOptions.RemoveEmptyEntries); 101 | license.PostalCode = remainingDataParts?.FirstOrDefault(); 102 | if (license.PostalCode is {Length: > 5}) 103 | { 104 | license.PostalCode = $"{license.PostalCode[..5]}-{license.PostalCode[5..]}"; 105 | } 106 | 107 | var vehicleClass = remainingDataParts?.ElementAtOrDefault(1); 108 | var unknownFieldTwo = remainingDataParts?.ElementAtOrDefault(2); 109 | var lastSectionStartIndex = 0; 110 | var lastSection = remainingDataParts?.ElementAtOrDefault(3); 111 | if (remainingDataParts is {Length: 5}) 112 | { 113 | lastSection += remainingDataParts.ElementAtOrDefault(4); 114 | } 115 | 116 | if (lastSection == null) 117 | { 118 | return license; 119 | } 120 | 121 | license.Gender = lastSection.SubstringSafe(lastSectionStartIndex, 1) is "1" or "M" 122 | ? Gender.Male 123 | : Gender.Female; 124 | lastSectionStartIndex++; 125 | license.Height = lastSection.SubstringSafe(lastSectionStartIndex, 3).ParseHeightInInches(); 126 | lastSectionStartIndex += 3; 127 | var weight = lastSection.SubstringSafe(lastSectionStartIndex, 3); 128 | lastSectionStartIndex += 3; 129 | license.HairColor = lastSection.SubstringSafe(lastSectionStartIndex, 3).ParseHairColor(); 130 | lastSectionStartIndex += 3; 131 | license.EyeColor = lastSection.SubstringSafe(lastSectionStartIndex, 3).ParseEyeColor(); 132 | return license; 133 | } 134 | } -------------------------------------------------------------------------------- /DLP.Tests/ParseableLicenses/NorthCarolinaTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Models; 2 | using DLP.Core.Models.Enums; 3 | using DLP.Core.ParseableLicenses; 4 | using FluentAssertions; 5 | using FluentAssertions.Execution; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Web; 9 | using Xunit; 10 | 11 | namespace DLP.Tests.ParseableLicenses; 12 | 13 | public static class NorthCarolinaTests 14 | { 15 | [Fact] 16 | public static void ValidateStateLicenseData() 17 | { 18 | // Arrange. 19 | var state = new NorthCarolina(); 20 | 21 | // Assert. 22 | using (new AssertionScope()) 23 | { 24 | state.FullName.Should().Be("North Carolina"); 25 | state.Abbreviation.Should().Be("NC"); 26 | state.Country.Should().Be(IssuingCountry.UnitedStates); 27 | state.IssuerIdentificationNumber.Should().Be(636004); 28 | } 29 | } 30 | 31 | [Theory] 32 | [InlineData("636004", true)] 33 | [InlineData("ha636004ha", true)] 34 | [InlineData("636014", false)] 35 | public static void IsDataFromEntityCorrectlyDetectsEntitiesData(string? input, bool expected) => 36 | new NorthCarolina().IsDataFromEntity(input).Should().Be(expected); 37 | 38 | public static IEnumerable GetDataSets() => 39 | new List 40 | { 41 | new object[] 42 | { 43 | "%40%0A%1E%0DAAMVA36004001DL00280195DLDABDOE%0ADACJOHN%0ADADD%0ADAE%0ADAL1234%20FAKE%20CT%0ADAM%0ADANMYCITY%0ADAONC%0ADAP28451-7030%0ADAQ123456789%0ADARC%0ADASNone%0ADATNone%0ADAV5-10%0ADAYBLU%0ADAZBRO%0ADBA06-19-2023%0ADBB06-19-2010%0ADBCM%0ADBD06-22-2015%0ADBHY%0D&", 44 | new DriversLicenseData 45 | { 46 | FirstName = "JOHN", 47 | MiddleName = "D", 48 | LastName = "DOE", 49 | DateOfBirth = new DateTimeOffset(2010, 6, 19, 0, 0, 0, TimeSpan.Zero), 50 | StreetAddress = "1234 FAKE CT", 51 | SecondStreetAddress = null, 52 | City = "MYCITY", 53 | State = "NC", 54 | PostalCode = "28451-7030", 55 | IssuingCountry = IssuingCountry.UnitedStates, 56 | DocumentId = "123456789", 57 | AuditInformation = null, 58 | FirstNameAlias = null, 59 | LastNameAlias = null, 60 | SuffixAlias = null, 61 | PlaceOfBirth = null, 62 | CustomerId = null, 63 | EyeColor = EyeColor.Blue, 64 | ExpirationDate = new DateTimeOffset(2023, 6, 19, 0, 0, 0, TimeSpan.Zero), 65 | IssueDate = new DateTimeOffset(2015, 6, 22, 0, 0, 0, TimeSpan.Zero), 66 | HairColor = HairColor.Brown, 67 | InventoryControl = "00280195", 68 | FirstNameTruncated = Truncation.Unknown, 69 | LastNameTruncated = Truncation.Unknown, 70 | MiddleNameTruncated = Truncation.Unknown, 71 | Gender = Gender.Unknown, 72 | Height = 70, 73 | NameSuffix = NameSuffix.Unknown, 74 | LicenseVersion = LicenseVersion.Version1 75 | } 76 | } 77 | }; 78 | 79 | [Theory, MemberData(nameof(GetDataSets))] 80 | public static void ParseData(string data, DriversLicenseData expected) 81 | { 82 | var driversLicenseData = new NorthCarolina().ParseData(HttpUtility.UrlDecode(data)); 83 | using (new AssertionScope()) 84 | { 85 | driversLicenseData.FirstName.Should().Be(expected.FirstName); 86 | driversLicenseData.MiddleName.Should().Be(expected.MiddleName); 87 | driversLicenseData.LastName.Should().Be(expected.LastName); 88 | driversLicenseData.DateOfBirth.Should().Be(expected.DateOfBirth); 89 | driversLicenseData.StreetAddress.Should().Be(expected.StreetAddress); 90 | driversLicenseData.SecondStreetAddress.Should().Be(expected.SecondStreetAddress); 91 | driversLicenseData.City.Should().Be(expected.City); 92 | driversLicenseData.State.Should().Be(expected.State); 93 | driversLicenseData.PostalCode.Should().Be(expected.PostalCode); 94 | driversLicenseData.IssuingCountry.Should().Be(expected.IssuingCountry); 95 | driversLicenseData.DocumentId.Should().Be(expected.DocumentId); 96 | driversLicenseData.AuditInformation.Should().Be(expected.AuditInformation); 97 | driversLicenseData.FirstNameAlias.Should().Be(expected.FirstNameAlias); 98 | driversLicenseData.LastNameAlias.Should().Be(expected.LastNameAlias); 99 | driversLicenseData.SuffixAlias.Should().Be(expected.SuffixAlias); 100 | driversLicenseData.PlaceOfBirth.Should().Be(expected.PlaceOfBirth); 101 | driversLicenseData.CustomerId.Should().Be(expected.CustomerId); 102 | driversLicenseData.EyeColor.Should().Be(expected.EyeColor); 103 | driversLicenseData.ExpirationDate.Should().Be(expected.ExpirationDate); 104 | driversLicenseData.IssueDate.Should().Be(expected.IssueDate); 105 | driversLicenseData.HairColor.Should().Be(expected.HairColor); 106 | driversLicenseData.InventoryControl.Should().Be(expected.InventoryControl); 107 | driversLicenseData.FirstNameTruncated.Should().Be(expected.FirstNameTruncated); 108 | driversLicenseData.LastNameTruncated.Should().Be(expected.LastNameTruncated); 109 | driversLicenseData.MiddleNameTruncated.Should().Be(expected.MiddleNameTruncated); 110 | driversLicenseData.Gender.Should().Be(expected.Gender); 111 | driversLicenseData.Height.Should().Be(expected.Height); 112 | driversLicenseData.NameSuffix.Should().Be(expected.NameSuffix); 113 | driversLicenseData.LicenseVersion.Should().Be(expected.LicenseVersion); 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /DLP.Tests/ParseableLicenses/UtahTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Models; 2 | using DLP.Core.Models.Enums; 3 | using DLP.Core.ParseableLicenses; 4 | using FluentAssertions; 5 | using FluentAssertions.Execution; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Web; 9 | using Xunit; 10 | 11 | namespace DLP.Tests.ParseableLicenses; 12 | 13 | public static class UtahTests 14 | { 15 | [Fact] 16 | public static void ValidateStateLicenseData() 17 | { 18 | // Arrange. 19 | var state = new Utah(); 20 | 21 | // Assert. 22 | using (new AssertionScope()) 23 | { 24 | state.FullName.Should().Be("Utah"); 25 | state.Abbreviation.Should().Be("UT"); 26 | state.Country.Should().Be(IssuingCountry.UnitedStates); 27 | state.IssuerIdentificationNumber.Should().Be(636040); 28 | } 29 | } 30 | 31 | [Theory] 32 | [InlineData("636040", true)] 33 | [InlineData("ha636040ha", true)] 34 | [InlineData("636140", false)] 35 | public static void IsDataFromEntityCorrectlyDetectsEntitiesData(string? input, bool expected) => 36 | new Utah().IsDataFromEntity(input).Should().Be(expected); 37 | 38 | public static IEnumerable GetDataSets() => 39 | new List 40 | { 41 | new object[] 42 | { 43 | "%40%0A%1E%0DANSI%20636040030002DL00410223ZU02640008DLDCAD%0ADCBB%0ADCD%0ADBA10162017%0ADCSDOE%0ADCTJOHN%2CD%2C%0ADBD10152012%0ADBB10162010%0ADBC1%0ADAYBRO%0ADAU%2070%20in%0ADAG1234 FAKE AVE%0ADAISALT%20LAKE%20CITY%0ADAJUT%0ADAK84115%20%20%20%20%20%20%0ADAQ123456789%0ADCF0123456789_108425421%0ADCGUSA%0ADCHNONE%0ADAZBROWN%0A%0DZUZUAY%0A%0D&", 44 | new DriversLicenseData 45 | { 46 | FirstName = "JOHN", 47 | MiddleName = "D", 48 | LastName = "DOE", 49 | DateOfBirth = new DateTimeOffset(2010, 10, 16, 0, 0, 0, TimeSpan.Zero), 50 | StreetAddress = "1234 FAKE AVE", 51 | SecondStreetAddress = null, 52 | City = "SALT LAKE CITY", 53 | State = "UT", 54 | PostalCode = "84115", 55 | IssuingCountry = IssuingCountry.UnitedStates, 56 | DocumentId = "0123456789_108425421", 57 | AuditInformation = null, 58 | FirstNameAlias = null, 59 | LastNameAlias = null, 60 | SuffixAlias = null, 61 | PlaceOfBirth = null, 62 | CustomerId = "123456789", 63 | EyeColor = EyeColor.Brown, 64 | ExpirationDate = new DateTimeOffset(2017, 10, 16, 0, 0, 0, TimeSpan.Zero), 65 | IssueDate = new DateTimeOffset(2012, 10, 15, 0, 0, 0, TimeSpan.Zero), 66 | HairColor = HairColor.Unknown, 67 | InventoryControl = null, 68 | FirstNameTruncated = Truncation.Unknown, 69 | LastNameTruncated = Truncation.Unknown, 70 | MiddleNameTruncated = Truncation.Unknown, 71 | Gender = Gender.Male, 72 | Height = 70, 73 | NameSuffix = NameSuffix.Unknown, 74 | LicenseVersion = LicenseVersion.Version3 75 | } 76 | } 77 | }; 78 | 79 | [Theory, MemberData(nameof(GetDataSets))] 80 | public static void ParseData(string data, DriversLicenseData expected) 81 | { 82 | var driversLicenseData = new Utah().ParseData(HttpUtility.UrlDecode(data)); 83 | using (new AssertionScope()) 84 | { 85 | driversLicenseData.FirstName.Should().Be(expected.FirstName); 86 | driversLicenseData.MiddleName.Should().Be(expected.MiddleName); 87 | driversLicenseData.LastName.Should().Be(expected.LastName); 88 | driversLicenseData.DateOfBirth.Should().Be(expected.DateOfBirth); 89 | driversLicenseData.StreetAddress.Should().Be(expected.StreetAddress); 90 | driversLicenseData.SecondStreetAddress.Should().Be(expected.SecondStreetAddress); 91 | driversLicenseData.City.Should().Be(expected.City); 92 | driversLicenseData.State.Should().Be(expected.State); 93 | driversLicenseData.PostalCode.Should().Be(expected.PostalCode); 94 | driversLicenseData.IssuingCountry.Should().Be(expected.IssuingCountry); 95 | driversLicenseData.DocumentId.Should().Be(expected.DocumentId); 96 | driversLicenseData.AuditInformation.Should().Be(expected.AuditInformation); 97 | driversLicenseData.FirstNameAlias.Should().Be(expected.FirstNameAlias); 98 | driversLicenseData.LastNameAlias.Should().Be(expected.LastNameAlias); 99 | driversLicenseData.SuffixAlias.Should().Be(expected.SuffixAlias); 100 | driversLicenseData.PlaceOfBirth.Should().Be(expected.PlaceOfBirth); 101 | driversLicenseData.CustomerId.Should().Be(expected.CustomerId); 102 | driversLicenseData.EyeColor.Should().Be(expected.EyeColor); 103 | driversLicenseData.ExpirationDate.Should().Be(expected.ExpirationDate); 104 | driversLicenseData.IssueDate.Should().Be(expected.IssueDate); 105 | driversLicenseData.HairColor.Should().Be(expected.HairColor); 106 | driversLicenseData.InventoryControl.Should().Be(expected.InventoryControl); 107 | driversLicenseData.FirstNameTruncated.Should().Be(expected.FirstNameTruncated); 108 | driversLicenseData.LastNameTruncated.Should().Be(expected.LastNameTruncated); 109 | driversLicenseData.MiddleNameTruncated.Should().Be(expected.MiddleNameTruncated); 110 | driversLicenseData.Gender.Should().Be(expected.Gender); 111 | driversLicenseData.Height.Should().Be(expected.Height); 112 | driversLicenseData.NameSuffix.Should().Be(expected.NameSuffix); 113 | driversLicenseData.LicenseVersion.Should().Be(expected.LicenseVersion); 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /DLP.Tests/ParseableLicenses/IllinoisTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Models; 2 | using DLP.Core.Models.Enums; 3 | using DLP.Core.ParseableLicenses; 4 | using FluentAssertions; 5 | using FluentAssertions.Execution; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Web; 9 | using Xunit; 10 | 11 | namespace DLP.Tests.ParseableLicenses; 12 | 13 | public static class IllinoisTests 14 | { 15 | [Fact] 16 | public static void ValidateStateLicenseData() 17 | { 18 | // Arrange. 19 | var state = new Illinois(); 20 | 21 | // Assert. 22 | using (new AssertionScope()) 23 | { 24 | state.FullName.Should().Be("Illinois"); 25 | state.Abbreviation.Should().Be("IL"); 26 | state.Country.Should().Be(IssuingCountry.UnitedStates); 27 | state.IssuerIdentificationNumber.Should().Be(636035); 28 | } 29 | } 30 | 31 | [Theory] 32 | [InlineData("636035", true)] 33 | [InlineData("ha636035ha", true)] 34 | [InlineData("636135", false)] 35 | public static void IsDataFromEntityCorrectlyDetectsEntitiesData(string? input, bool expected) => 36 | new Illinois().IsDataFromEntity(input).Should().Be(expected); 37 | 38 | public static IEnumerable GetDataSets() => 39 | new List 40 | { 41 | new object[] 42 | { 43 | "%40%0A%0DANSI%206360350201DL00290190DLDAADOE,JOHN,CHESTER%0ADAQ123456789%0ADBA20181224%0ADBB20100428%0ADAG1234 FAKE BLVD%0ADAIMYCITY%0ADAJIL%0ADAK442240000%20%20%0ADARD%0ADAS********%20%20%0ADAT*****%0ADBD20140529%0ADBCF%0ADAU503%0ADAW125%0ADAYBLU%0A%0D", 44 | new DriversLicenseData 45 | { 46 | FirstName = "JOHN", 47 | MiddleName = "CHESTER", 48 | LastName = "DOE", 49 | DateOfBirth = new DateTimeOffset(2010, 4, 28, 0, 0, 0, TimeSpan.Zero), 50 | StreetAddress = "1234 FAKE BLVD", 51 | SecondStreetAddress = null, 52 | City = "MYCITY", 53 | State = "IL", 54 | PostalCode = "44224", 55 | IssuingCountry = IssuingCountry.UnitedStates, 56 | DocumentId = null, 57 | AuditInformation = null, 58 | FirstNameAlias = null, 59 | LastNameAlias = null, 60 | SuffixAlias = null, 61 | PlaceOfBirth = null, 62 | CustomerId = "123456789", 63 | EyeColor = EyeColor.Blue, 64 | ExpirationDate = new DateTimeOffset(2018, 12, 24, 0, 0, 0, TimeSpan.Zero), 65 | IssueDate = new DateTimeOffset(2014, 5, 29, 0, 0, 0, TimeSpan.Zero), 66 | HairColor = HairColor.Unknown, 67 | InventoryControl = "00290190", 68 | FirstNameTruncated = Truncation.Unknown, 69 | LastNameTruncated = Truncation.Unknown, 70 | MiddleNameTruncated = Truncation.Unknown, 71 | Gender = Gender.Unknown, 72 | Height = 63, 73 | NameSuffix = NameSuffix.Unknown, 74 | LicenseVersion = LicenseVersion.Version2 75 | } 76 | }, 77 | new object[] 78 | { 79 | "%40%0A%1C%0DANSI+6360350201DL00290190DLDAADOE%2CJOHN%2CCHESTER%0ADAQ123456789%0ADBA20181224%0ADBB20100428%0ADAG1234 FAKE BLVD%0ADAIMYCITY%0ADAJIL%0ADAK442240000++%0ADARD%0ADAS********++%0ADAT*****%0ADBD20140529%0ADBCF%0ADAU503%0ADAW125%0ADAYBLU%0A%0D", 80 | new DriversLicenseData 81 | { 82 | FirstName = "JOHN", 83 | MiddleName = "CHESTER", 84 | LastName = "DOE", 85 | DateOfBirth = new DateTimeOffset(2010, 4, 28, 0, 0, 0, TimeSpan.Zero), 86 | StreetAddress = "1234 FAKE BLVD", 87 | SecondStreetAddress = null, 88 | City = "MYCITY", 89 | State = "IL", 90 | PostalCode = "44224", 91 | IssuingCountry = IssuingCountry.UnitedStates, 92 | DocumentId = null, 93 | AuditInformation = null, 94 | FirstNameAlias = null, 95 | LastNameAlias = null, 96 | SuffixAlias = null, 97 | PlaceOfBirth = null, 98 | CustomerId = "123456789", 99 | EyeColor = EyeColor.Blue, 100 | ExpirationDate = new DateTimeOffset(2018, 12, 24, 0, 0, 0, TimeSpan.Zero), 101 | IssueDate = new DateTimeOffset(2014, 5, 29, 0, 0, 0, TimeSpan.Zero), 102 | HairColor = HairColor.Unknown, 103 | InventoryControl = "00290190", 104 | FirstNameTruncated = Truncation.Unknown, 105 | LastNameTruncated = Truncation.Unknown, 106 | MiddleNameTruncated = Truncation.Unknown, 107 | Gender = Gender.Unknown, 108 | Height = 63, 109 | NameSuffix = NameSuffix.Unknown, 110 | LicenseVersion = LicenseVersion.Version2 111 | } 112 | } 113 | }; 114 | 115 | [Theory, MemberData(nameof(GetDataSets))] 116 | public static void ParseData(string data, DriversLicenseData expected) 117 | { 118 | var driversLicenseData = new Illinois().ParseData(HttpUtility.UrlDecode(data)); 119 | using (new AssertionScope()) 120 | { 121 | driversLicenseData.FirstName.Should().Be(expected.FirstName); 122 | driversLicenseData.MiddleName.Should().Be(expected.MiddleName); 123 | driversLicenseData.LastName.Should().Be(expected.LastName); 124 | driversLicenseData.DateOfBirth.Should().Be(expected.DateOfBirth); 125 | driversLicenseData.StreetAddress.Should().Be(expected.StreetAddress); 126 | driversLicenseData.SecondStreetAddress.Should().Be(expected.SecondStreetAddress); 127 | driversLicenseData.City.Should().Be(expected.City); 128 | driversLicenseData.State.Should().Be(expected.State); 129 | driversLicenseData.PostalCode.Should().Be(expected.PostalCode); 130 | driversLicenseData.IssuingCountry.Should().Be(expected.IssuingCountry); 131 | driversLicenseData.DocumentId.Should().Be(expected.DocumentId); 132 | driversLicenseData.AuditInformation.Should().Be(expected.AuditInformation); 133 | driversLicenseData.FirstNameAlias.Should().Be(expected.FirstNameAlias); 134 | driversLicenseData.LastNameAlias.Should().Be(expected.LastNameAlias); 135 | driversLicenseData.SuffixAlias.Should().Be(expected.SuffixAlias); 136 | driversLicenseData.PlaceOfBirth.Should().Be(expected.PlaceOfBirth); 137 | driversLicenseData.CustomerId.Should().Be(expected.CustomerId); 138 | driversLicenseData.EyeColor.Should().Be(expected.EyeColor); 139 | driversLicenseData.ExpirationDate.Should().Be(expected.ExpirationDate); 140 | driversLicenseData.IssueDate.Should().Be(expected.IssueDate); 141 | driversLicenseData.HairColor.Should().Be(expected.HairColor); 142 | driversLicenseData.InventoryControl.Should().Be(expected.InventoryControl); 143 | driversLicenseData.FirstNameTruncated.Should().Be(expected.FirstNameTruncated); 144 | driversLicenseData.LastNameTruncated.Should().Be(expected.LastNameTruncated); 145 | driversLicenseData.MiddleNameTruncated.Should().Be(expected.MiddleNameTruncated); 146 | driversLicenseData.Gender.Should().Be(expected.Gender); 147 | driversLicenseData.Height.Should().Be(expected.Height); 148 | driversLicenseData.NameSuffix.Should().Be(expected.NameSuffix); 149 | driversLicenseData.LicenseVersion.Should().Be(expected.LicenseVersion); 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /DLP.Tests/ParseableLicenses/ConnecticutTests.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Models; 2 | using DLP.Core.Models.Enums; 3 | using DLP.Core.ParseableLicenses; 4 | using FluentAssertions; 5 | using FluentAssertions.Execution; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Web; 9 | using Xunit; 10 | 11 | namespace DLP.Tests.ParseableLicenses; 12 | 13 | public static class ConnecticutTests 14 | { 15 | [Fact] 16 | public static void ValidateOhioLicenseData() 17 | { 18 | // Arrange. 19 | var state = new Connecticut(); 20 | 21 | // Assert. 22 | using (new AssertionScope()) 23 | { 24 | state.FullName.Should().Be("Connecticut"); 25 | state.Abbreviation.Should().Be("CT"); 26 | state.Country.Should().Be(IssuingCountry.UnitedStates); 27 | state.IssuerIdentificationNumber.Should().Be(636006); 28 | } 29 | } 30 | 31 | [Theory] 32 | [InlineData("636006", true)] 33 | [InlineData("ha636006ha", true)] 34 | [InlineData("636125", false)] 35 | public static void IsDataFromEntityCorrectlyDetectsEntitiesData(string? input, bool expected) => 36 | new Connecticut().IsDataFromEntity(input).Should().Be(expected); 37 | 38 | public static IEnumerable GetDataSets() => 39 | new List 40 | { 41 | new object[] 42 | { 43 | "%40%0A%1E%0DAAMVA6360060101DL00290175DAADOE%2CJOHN%2CCHESTER%0ADAG1234 FAKE BLVD%0ADAIMYCITY%0ADAJCT%0ADAK44224+++++%0ADAQ123456789%0ADARD+%0ADAS++++++++%0ADAT++++%0ADBA20210701%0ADBB20100428%0ADBC2%0ADBD20150618%0ADAU507%0ADAYHAZ%0ADBF00%0ADBHN%0D", 44 | new DriversLicenseData 45 | { 46 | FirstName = "JOHN", 47 | MiddleName = "CHESTER", 48 | LastName = "DOE", 49 | DateOfBirth = new DateTimeOffset(2010, 4, 28, 0, 0, 0, TimeSpan.Zero), 50 | StreetAddress = "1234 FAKE BLVD", 51 | SecondStreetAddress = null, 52 | City = "MYCITY", 53 | State = "CT", 54 | PostalCode = "44224", 55 | IssuingCountry = IssuingCountry.UnitedStates, 56 | DocumentId = null, 57 | AuditInformation = null, 58 | FirstNameAlias = null, 59 | LastNameAlias = null, 60 | SuffixAlias = null, 61 | PlaceOfBirth = null, 62 | CustomerId = null, 63 | EyeColor = EyeColor.Hazel, 64 | ExpirationDate = new DateTimeOffset(2021, 7, 1, 0, 0, 0, TimeSpan.Zero), 65 | IssueDate = new DateTimeOffset(2015, 6, 18, 0, 0, 0, TimeSpan.Zero), 66 | HairColor = HairColor.Unknown, 67 | InventoryControl = "00290175", 68 | FirstNameTruncated = Truncation.Unknown, 69 | LastNameTruncated = Truncation.Unknown, 70 | MiddleNameTruncated = Truncation.Unknown, 71 | Gender = Gender.Female, 72 | Height = 67, 73 | NameSuffix = NameSuffix.Unknown, 74 | LicenseVersion = LicenseVersion.Version1 75 | } 76 | }, 77 | new object[] 78 | { 79 | "%40%0A%0DAAMVA6360060101DL00290175DAADOE,JOHN,CHESTER%0ADAG1234 FAKE BLVD%0ADAIMYCITY%0ADAJCT%0ADAK44224%20%20%20%20%20%20%0ADAQ123456789%0ADARD%20%20%20%0ADAS%20%20%20%20%20%20%20%20%20%20%0ADAT%20%20%20%20%20%0ADBA20210701%0ADBB20100428%0ADBC2%0ADBD20150618%0ADAU507%0ADAYHAZ%0ADBF00%0ADBHN%0D", 80 | new DriversLicenseData 81 | { 82 | FirstName = "JOHN", 83 | MiddleName = "CHESTER", 84 | LastName = "DOE", 85 | DateOfBirth = new DateTimeOffset(2010, 4, 28, 0, 0, 0, TimeSpan.Zero), 86 | StreetAddress = "1234 FAKE BLVD", 87 | SecondStreetAddress = null, 88 | City = "MYCITY", 89 | State = "CT", 90 | PostalCode = "44224", 91 | IssuingCountry = IssuingCountry.UnitedStates, 92 | DocumentId = null, 93 | AuditInformation = null, 94 | FirstNameAlias = null, 95 | LastNameAlias = null, 96 | SuffixAlias = null, 97 | PlaceOfBirth = null, 98 | CustomerId = null, 99 | EyeColor = EyeColor.Hazel, 100 | ExpirationDate = new DateTimeOffset(2021, 7, 1, 0, 0, 0, TimeSpan.Zero), 101 | IssueDate = new DateTimeOffset(2015, 6, 18, 0, 0, 0, TimeSpan.Zero), 102 | HairColor = HairColor.Unknown, 103 | InventoryControl = "00290175", 104 | FirstNameTruncated = Truncation.Unknown, 105 | LastNameTruncated = Truncation.Unknown, 106 | MiddleNameTruncated = Truncation.Unknown, 107 | Gender = Gender.Female, 108 | Height = 67, 109 | NameSuffix = NameSuffix.Unknown, 110 | LicenseVersion = LicenseVersion.Version1 111 | } 112 | } 113 | }; 114 | 115 | [Theory, MemberData(nameof(GetDataSets))] 116 | public static void ParseData(string data, DriversLicenseData expected) 117 | { 118 | var driversLicenseData = new Connecticut().ParseData(HttpUtility.UrlDecode(data)); 119 | using (new AssertionScope()) 120 | { 121 | driversLicenseData.FirstName.Should().Be(expected.FirstName); 122 | driversLicenseData.MiddleName.Should().Be(expected.MiddleName); 123 | driversLicenseData.LastName.Should().Be(expected.LastName); 124 | driversLicenseData.DateOfBirth.Should().Be(expected.DateOfBirth); 125 | driversLicenseData.StreetAddress.Should().Be(expected.StreetAddress); 126 | driversLicenseData.SecondStreetAddress.Should().Be(expected.SecondStreetAddress); 127 | driversLicenseData.City.Should().Be(expected.City); 128 | driversLicenseData.State.Should().Be(expected.State); 129 | driversLicenseData.PostalCode.Should().Be(expected.PostalCode); 130 | driversLicenseData.IssuingCountry.Should().Be(expected.IssuingCountry); 131 | driversLicenseData.DocumentId.Should().Be(expected.DocumentId); 132 | driversLicenseData.AuditInformation.Should().Be(expected.AuditInformation); 133 | driversLicenseData.FirstNameAlias.Should().Be(expected.FirstNameAlias); 134 | driversLicenseData.LastNameAlias.Should().Be(expected.LastNameAlias); 135 | driversLicenseData.SuffixAlias.Should().Be(expected.SuffixAlias); 136 | driversLicenseData.PlaceOfBirth.Should().Be(expected.PlaceOfBirth); 137 | driversLicenseData.CustomerId.Should().Be(expected.CustomerId); 138 | driversLicenseData.EyeColor.Should().Be(expected.EyeColor); 139 | driversLicenseData.ExpirationDate.Should().Be(expected.ExpirationDate); 140 | driversLicenseData.IssueDate.Should().Be(expected.IssueDate); 141 | driversLicenseData.HairColor.Should().Be(expected.HairColor); 142 | driversLicenseData.InventoryControl.Should().Be(expected.InventoryControl); 143 | driversLicenseData.FirstNameTruncated.Should().Be(expected.FirstNameTruncated); 144 | driversLicenseData.LastNameTruncated.Should().Be(expected.LastNameTruncated); 145 | driversLicenseData.MiddleNameTruncated.Should().Be(expected.MiddleNameTruncated); 146 | driversLicenseData.Gender.Should().Be(expected.Gender); 147 | driversLicenseData.Height.Should().Be(expected.Height); 148 | driversLicenseData.NameSuffix.Should().Be(expected.NameSuffix); 149 | driversLicenseData.LicenseVersion.Should().Be(expected.LicenseVersion); 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /DLP.Core/Parsers/Version3StandardParser.cs: -------------------------------------------------------------------------------- 1 | using DLP.Core.Helpers; 2 | using DLP.Core.Models; 3 | using DLP.Core.Models.Enums; 4 | using System.Collections.Generic; 5 | // ReSharper disable UnusedMember.Global 6 | 7 | namespace DLP.Core.Parsers; 8 | 9 | /// 10 | /// Represents an AAMVA Version 3 license. 11 | /// 12 | public static class Version3StandardParser 13 | { 14 | /// 15 | /// Parses an AAMVA Version 3 license. 16 | /// 17 | /// The incoming raw data. 18 | /// The raw data split per this versions rules. 19 | /// 20 | public static DriversLicenseData ParseDriversLicenseData( 21 | string? data, 22 | out IReadOnlyDictionary splitUpData) 23 | { 24 | splitUpData = ParsingHelpers.SplitLicenseString(data); 25 | return new DriversLicenseData 26 | { 27 | // Pulling the "Last" name because the first name is where the last name should be. 28 | FirstName = splitUpData.ParseDriverLicenseName(Version3StandardMarkers.FirstNameMarker, NamePart.LastName), 29 | LastName = splitUpData.TryGetValue(Version3StandardMarkers.LastNameMarker), 30 | MiddleName = splitUpData.TryGetValue(Version3StandardMarkers.MiddleNameMarker) 31 | ?? splitUpData.ParseDriverLicenseName(Version3StandardMarkers.FirstNameMarker, NamePart.ShortMiddleName), 32 | ExpirationDate = splitUpData.TryGetValue(Version3StandardMarkers.ExpirationDateMarker).ParseDateTimeMdyThenYmd(), 33 | IssueDate = splitUpData.TryGetValue(Version3StandardMarkers.IssueDateMarker).ParseDateTimeMdyThenYmd(), 34 | DateOfBirth = splitUpData.TryGetValue(Version3StandardMarkers.DateOfBirthMarker).ParseDateTimeMdyThenYmd(), 35 | Gender = splitUpData.TryGetValue(Version3StandardMarkers.GenderMarker).ParseGender(), 36 | EyeColor = splitUpData.TryGetValue(Version3StandardMarkers.EyeColorMarker).ParseEyeColor(), 37 | Height = splitUpData.TryGetValue(Version3StandardMarkers.HeightMarker).ParseHeightInInches(), 38 | StreetAddress = splitUpData.TryGetValue(Version3StandardMarkers.StreetAddressMarker), 39 | City = splitUpData.TryGetValue(Version3StandardMarkers.CityMarker), 40 | State = splitUpData.TryGetValue(Version3StandardMarkers.StateMarker), 41 | PostalCode = splitUpData.TryGetValue(Version3StandardMarkers.PostalCodeMarker).TrimTrailingZerosFromZipCode(), 42 | CustomerId = splitUpData.TryGetValue(Version3StandardMarkers.CustomerIdMarker), 43 | DocumentId = splitUpData.TryGetValue(Version3StandardMarkers.DocumentIdMarker), 44 | IssuingCountry = splitUpData.TryGetValue(Version3StandardMarkers.IssuingCountryMarker).ParseIssuingCountry(), 45 | SecondStreetAddress = splitUpData.TryGetValue(Version3StandardMarkers.SecondStreetAddressMarker), 46 | HairColor = splitUpData.TryGetValue(Version3StandardMarkers.HairColorMarker).ParseHairColor(), 47 | PlaceOfBirth = splitUpData.TryGetValue(Version3StandardMarkers.PlaceOfBirthMarker), 48 | AuditInformation = splitUpData.TryGetValue(Version3StandardMarkers.AuditInformationMarker), 49 | InventoryControl = splitUpData.TryGetValue(Version3StandardMarkers.InventoryControlMarker), 50 | LastNameAlias = splitUpData.TryGetValue(Version3StandardMarkers.LastNameAliasMarker), 51 | FirstNameAlias = splitUpData.TryGetValue(Version3StandardMarkers.FirstNameAliasMarker), 52 | SuffixAlias = splitUpData.TryGetValue(Version3StandardMarkers.SuffixAliasMarker), 53 | NameSuffix = splitUpData.TryGetValue(Version3StandardMarkers.NameSuffixMarker).ParseNameSuffix(), 54 | LicenseVersion = LicenseVersion.Version3 55 | }; 56 | } 57 | 58 | /// 59 | /// AAMVA Version 3 license data codes 60 | /// 61 | /// 62 | /// These codes are used to mark where in the text data a certain field starts. 63 | /// 64 | public static class Version3StandardMarkers 65 | { 66 | /// 67 | /// DCT 68 | /// 69 | public const string FirstNameMarker = "DCT"; 70 | 71 | /// 72 | /// DCS 73 | /// 74 | public const string LastNameMarker = "DCS"; 75 | 76 | /// 77 | /// DAD 78 | /// 79 | public const string MiddleNameMarker = "DAD"; 80 | 81 | /// 82 | /// DBA 83 | /// 84 | public const string ExpirationDateMarker = "DBA"; 85 | 86 | /// 87 | /// DBD 88 | /// 89 | public const string IssueDateMarker = "DBD"; 90 | 91 | /// 92 | /// DBB 93 | /// 94 | public const string DateOfBirthMarker = "DBB"; 95 | 96 | /// 97 | /// DBC 98 | /// 99 | public const string GenderMarker = "DBC"; 100 | 101 | /// 102 | /// DAY 103 | /// 104 | public const string EyeColorMarker = "DAY"; 105 | 106 | /// 107 | /// DAU 108 | /// 109 | public const string HeightMarker = "DAU"; 110 | 111 | /// 112 | /// DAG 113 | /// 114 | public const string StreetAddressMarker = "DAG"; 115 | 116 | /// 117 | /// DAI 118 | /// 119 | public const string CityMarker = "DAI"; 120 | 121 | /// 122 | /// DAJ 123 | /// 124 | public const string StateMarker = "DAJ"; 125 | 126 | /// 127 | /// DAK 128 | /// 129 | public const string PostalCodeMarker = "DAK"; 130 | 131 | /// 132 | /// DAQ 133 | /// 134 | public const string CustomerIdMarker = "DAQ"; 135 | 136 | /// 137 | /// DCF 138 | /// 139 | public const string DocumentIdMarker = "DCF"; 140 | 141 | /// 142 | /// DCG 143 | /// 144 | public const string IssuingCountryMarker = "DCG"; 145 | 146 | /// 147 | /// Not used in this version. 148 | /// 149 | public const string MiddleNameTruncatedMarker = null!; 150 | 151 | /// 152 | /// Not used in this version. 153 | /// 154 | public const string FirstNameTruncatedMarker = null!; 155 | 156 | /// 157 | /// Not used in this version. 158 | /// 159 | public const string LastNameTruncatedMarker = null!; 160 | 161 | /// 162 | /// DAH 163 | /// 164 | public const string SecondStreetAddressMarker = "DAH"; 165 | 166 | /// 167 | /// DAZ 168 | /// 169 | public const string HairColorMarker = "DAZ"; 170 | 171 | /// 172 | /// DCI 173 | /// 174 | public const string PlaceOfBirthMarker = "DCI"; 175 | 176 | /// 177 | /// DCJ 178 | /// 179 | public const string AuditInformationMarker = "DCJ"; 180 | 181 | /// 182 | /// DCK 183 | /// 184 | public const string InventoryControlMarker = "DCK"; 185 | 186 | /// 187 | /// DBN 188 | /// 189 | public const string LastNameAliasMarker = "DBN"; 190 | 191 | /// 192 | /// DBG 193 | /// 194 | public const string FirstNameAliasMarker = "DBG"; 195 | 196 | /// 197 | /// DBS 198 | /// 199 | public const string SuffixAliasMarker = "DBS"; 200 | 201 | /// 202 | /// DCU 203 | /// 204 | public const string NameSuffixMarker = "DCU"; 205 | } 206 | } --------------------------------------------------------------------------------