├── 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 | [](https://github.com/joshuaquiz/DriversLicenseParser/blob/main/LICENSE)
2 | [](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 | [](https://github.com/joshuaquiz/DriversLicenseParser/blob/main/LICENSE)
2 | [](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