ktsu.Semantics.Strings.Identifiers 3.0.1

Prefix Reserved
dotnet add package ktsu.Semantics.Strings.Identifiers --version 3.0.1
                    
NuGet\Install-Package ktsu.Semantics.Strings.Identifiers -Version 3.0.1
                    
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="ktsu.Semantics.Strings.Identifiers" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.Semantics.Strings.Identifiers" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.Semantics.Strings.Identifiers" />
                    
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 ktsu.Semantics.Strings.Identifiers --version 3.0.1
                    
#r "nuget: ktsu.Semantics.Strings.Identifiers, 3.0.1"
                    
#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 ktsu.Semantics.Strings.Identifiers@3.0.1
                    
#: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=ktsu.Semantics.Strings.Identifiers&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.Semantics.Strings.Identifiers&version=3.0.1
                    
Install as a Cake Tool

ktsu.Semantics.Strings.Identifiers

Ready-made, self-validating identifier string types (Uuid, Ulid, Iban, Isbn, CreditCardNumber, JwtToken) built on the Semantics.Strings framework.

License NuGet Version NuGet Version NuGet Downloads GitHub commit activity GitHub contributors GitHub Actions Workflow Status

ktsu.Semantics.Strings.Identifiers is one package in the ktsu.Semantics family. It builds on ktsu.Semantics.Strings, which you should read first for the underlying SemanticString<T> model.

Introduction

Defining your own semantic string types is the core use of the framework, but a handful of identifier formats show up in almost every codebase. ktsu.Semantics.Strings.Identifiers ships six of them ready to use, each with real normalization and real check-digit or structural validation. You get compile-time-distinct types with no boilerplate.

Validation is pragmatic rather than exhaustive, with documented limits. For example JwtToken verifies the three-segment structure and that the header and payload decode to JSON objects, but it does not verify the signature.

Features

  • Six identifier types: Uuid, Ulid, Iban, Isbn, CreditCardNumber, JwtToken.
  • Normalization on creation: whitespace and separators stripped, casing folded to the canonical form for each format.
  • Real validation: check-digit maths for Iban (ISO 7064 mod-97), Isbn (mod-11 / mod-10), and CreditCardNumber (Luhn), structural and format rules for Uuid, Ulid, and JwtToken.
  • Same surface as any semantic string: Create, TryCreate, As<T>(), value equality, ordering, implicit string conversion, and JSON round-tripping, all inherited from SemanticString<T>.

Installation

Package Manager Console

Install-Package ktsu.Semantics.Strings.Identifiers

.NET CLI

dotnet add package ktsu.Semantics.Strings.Identifiers

Package Reference

<PackageReference Include="ktsu.Semantics.Strings.Identifiers" Version="x.y.z" />

Usage Examples

Basic Example

using ktsu.Semantics.Strings.Identifiers;

Uuid id = Uuid.Create("{123E4567-E89B-12D3-A456-426614174000}"); // -> "123e4567-e89b-12d3-a456-426614174000"
Ulid ulid = Ulid.Create("01ARZ3NDEKTSV4RRFFQ69G5FAV");
Isbn isbn = Isbn.Create("978-0-306-40615-7");                     // ISBN-10 or ISBN-13, check-digit validated
Iban iban = Iban.Create("GB82 WEST 1234 5698 7654 32");           // whitespace stripped, mod-97 validated

Uuid.Create("not-a-uuid"); // throws ArgumentException

Safe creation and normalization

using ktsu.Semantics.Strings.Identifiers;

// TryCreate never throws
if (CreditCardNumber.TryCreate("4111 1111 1111 1111", out CreditCardNumber? card))
{
    // separators stripped, Luhn-checked; card.WeakString == "4111111111111111"
}

// The .As<T>() extension works too
CreditCardNumber same = "4111-1111-1111-1111".As<CreditCardNumber>();

Every type inherits the full SemanticString<T> factory surface (Create, TryCreate, the char[] and ReadOnlySpan<char> overloads, As<T>()), so anything shown in the Semantics.Strings README applies here as well.

API Reference

Each type is a sealed record deriving from SemanticString<T>. None declare their own Create/TryCreate, they inherit them. The table describes what each type normalizes and validates.

Type Normalization Validation Documented limits
Uuid Trim, strip wrapping {} / (), lowercase Canonical 8-4-4-4-12 hex (RFC 4122 layout) Any variant/version accepted, including the nil UUID. Not version-checked.
Ulid Trim, uppercase 26 Crockford base32 chars, first char 0-7 Timestamp is not otherwise decoded.
Iban Strip spaces, uppercase Length 15-34, country/check prefix, ISO 7064 mod-97-10 checksum Country-specific BBAN structure is not enforced.
Isbn Strip - and spaces, uppercase ISBN-10 (weighted mod-11, X allowed) or ISBN-13 (mod-10) Registration-group/publisher ranges are not validated.
CreditCardNumber Strip spaces and hyphens 13-19 digits, Luhn (mod-10) checksum Luhn only. No issuer/network detection, no PCI guarantee. The value is sensitive, do not log it.
JwtToken None (stored verbatim, case-sensitive) Three .-separated segments, non-empty header and payload that decode to JSON objects Signature is not decoded or verified. alg, claims, and expiry are not inspected.

Creation follows the base-type contract: Create(...) throws ArgumentException on invalid input and ArgumentNullException on null, while TryCreate(...) returns false instead.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.0.1 0 8/18/2026
3.0.0 83 8/15/2026
2.9.14 72 8/14/2026
2.9.13 80 8/14/2026
2.9.12 81 8/14/2026
2.9.11 79 8/14/2026
2.9.10 74 8/14/2026
2.9.9 82 8/14/2026
2.9.8 75 8/14/2026
2.9.7 88 8/14/2026
2.9.6 89 8/14/2026
2.9.5 78 8/14/2026
2.9.4 86 8/14/2026
2.9.3 96 8/7/2026
2.9.2 84 8/6/2026
2.9.1 90 8/5/2026
2.9.0 104 8/4/2026
2.8.1 101 7/31/2026
2.8.0 103 7/30/2026
2.7.11 100 7/29/2026
Loading failed

## v3.0.1 (patch)

Changes since v3.0.0:

- Bump the ktsu group with 1 update ([@dependabot[bot]](https://github.com/dependabot[bot]))