IdParser.Core 3.2.0

dotnet add package IdParser.Core --version 3.2.0
                    
NuGet\Install-Package IdParser.Core -Version 3.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IdParser.Core" Version="3.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IdParser.Core" Version="3.2.0" />
                    
Directory.Packages.props
<PackageReference Include="IdParser.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IdParser.Core --version 3.2.0
                    
#r "nuget: IdParser.Core, 3.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IdParser.Core@3.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IdParser.Core&version=3.2.0
                    
Install as a Cake Addin
#tool nuget:?package=IdParser.Core&version=3.2.0
                    
Install as a Cake Tool

IdParser.Core

publish NuGet

IdParser.Core can be used to parse AAMVA-compliant driver's licenses and ID cards into objects that you can work with. More information on the versions of the AAMVA standard can be found here. More information on the D20 Data Dictionary can be found here.

Usage

  1. Include the using
using IdParser.Core;
  1. Then you're off to the races!
var parseResult = Barcode.Parse(barcode);
Console.WriteLine(parseResult.Card.StreetLine1.Value); // "123 NORTH STATE ST."
Console.WriteLine(parseResult.Card.IssuerIdentificationNumber.Value.GetDescriptionOrDefault()); // "New York"

if (parseResult.Card is DriversLicense license)
{
    Console.WriteLine(license.Jurisdiction.VehicleClass.Value); // "C"
}

If a field fails to parse, you can inspect the field's raw value:

if (parseResult.Card.FirstName.HasError)
{
    Console.WriteLine(parseResult.Card.FirstName.Error); // The error message, if any.
    Console.WriteLine(parseResult.Card.FirstName.RawValue); // The raw value from the scanned ID text.
}

You can iterate through all errors that occurred:

if (parseResult.Errors.Count > 0)
{
    foreach (var error in parseResult.Errors)
    {
        // All errors have a Message describing what went wrong.
        Console.WriteLine($"Error: {error.Message}");

        // Element-level errors will have an Element ID and the element's raw value.
        Console.WriteLine($"Element ID: {error.ElementId}");
        Console.WriteLine($"Raw Value: {error.RawValue}");
    }
}

You can also check to see whether a field was present in the scanned ID text:

Console.WriteLine($"First Name present? {parseResult.Card.FirstName.Present}");

More Examples

Take a look at the unit test project for more examples and usage.

Client

The IdParser.Core.Client project is a handy GUI application to help test and verify that an ID will be parsed correctly. The app works with both OPOS and HID keyboard emulation scanners.

alternate text is missing from this package README image

Credit

This is a fork of Connor O'Shea's IdParser library. Big thanks to him for all of his work.

The main changes I made for v1.0.0 of IdParser.Core are:

  • Dropped support for .NET Framework. If you need that, please use the original IdParser.
  • Supports only .NET 6 and above. If you need support for earlier versions of .NET/.NET Core, please use the original IdParser.
  • The parser classes are now static and no longer instantiated by Activator.CreateInstance. This reduced memory allocations per call considerably, and also sped things up.
  • The Abbreviation, Country, and Description attribute values are now cached so that we don't have to repeatedly use reflection to get their values.
  • Unhandled parsing exceptions are now rethrown, regardless of what the caller passes for the validation level (None or Strict).
  • Where possible, modernized the code base to use newer framework and language features, such as Span<T>.
  • The return value of Parse is now an object that returns both the ID card and a collection of any unknown element Ids.
  • Parse now accepts an optional Microsoft.Extensions.Logging.ILoggerFactory parameter. When not null, the library will log to an instance of ILogger.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.0 242 11/15/2025
3.2.0-alpha1 141 10/15/2025
3.1.0 1,009 11/20/2024
3.0.0 1,362 3/28/2024
3.0.0-beta3 204 3/21/2024
3.0.0-beta2 171 3/21/2024
3.0.0-beta1 174 3/12/2024
3.0.0-alpha2 168 3/12/2024
3.0.0-alpha1 169 3/7/2024
2.0.0 266 3/7/2024
2.0.0-alpha5 270 1/10/2024
2.0.0-alpha4 155 1/10/2024
2.0.0-alpha3 143 1/10/2024
2.0.0-alpha2 186 12/23/2023
2.0.0-alpha1 227 12/16/2023
1.1.0 385 12/14/2023
1.0.4 267 12/5/2023
1.0.3 306 10/26/2023
1.0.2 253 9/27/2023
1.0.1 239 9/27/2023
1.0.0 243 9/20/2023
1.0.0-beta8 247 9/8/2023
1.0.0-beta7 236 9/8/2023
1.0.0-beta6 243 9/8/2023
1.0.0-beta5 243 9/8/2023
1.0.0-beta4 260 8/8/2023
1.0.0-beta3 256 7/24/2023
1.0.0-beta2 272 7/23/2023
1.0.0-beta1 230 7/22/2023
1.0.0-alpha9 254 7/22/2023
1.0.0-alpha8 250 7/22/2023
1.0.0-alpha7 278 7/22/2023
1.0.0-alpha6 240 7/22/2023
1.0.0-alpha5 252 7/22/2023
1.0.0-alpha4 261 7/22/2023
1.0.0-alpha3 255 7/22/2023
1.0.0-alpha2 227 7/22/2023
1.0.0-alpha11 228 7/22/2023
1.0.0-alpha10 237 7/22/2023
1.0.0-alpha1 233 7/22/2023