Civitas.Id.Sweden 1.0.0

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

Civitas.Id.Sweden

NuGet

AOT-native .NET library for parsing, validating, and formatting Swedish official ID numbers (personnummer, samordningsnummer, organisationsnummer). Zero third-party runtime dependencies.

Install

dotnet add package Civitas.Id.Sweden

Usage

using Civitas.Id.Sweden.Core;
using Civitas.Id.Sweden.Format;

// Parse and validate
var person = PersonalId.Parse("198112189876");

// Read core facts
DateOnly birth = person.BirthDate;
bool adult = person.IsAdult();

// Format
string long12 = person.LongFormat();              // "198112189876"
string short10 = person.ShortFormat(PnrFormat.ShortFormat);            // "8112189876"
string short11 = person.ShortFormat(PnrFormat.ShortFormatWithSeparator); // "811218-9876"

// TryParse never throws
if (PersonalId.TryParse("198112180000", out var maybe))
{
    // ...
}

// Sealed sum type: PersonalId, CoordinationId, OrganisationId all : SwedishOfficialId
var any = SwedishOfficialId.ParseAny("5567203067");  // OrganisationId

Documentation

See the main repository for the full overview, behavioural rules (Stockholm civil-time anchor, leap-day handling, century inference), and companion packages (Civitas.Id.Sweden.Json, .DataAnnotations, .AspNetCore, .Fakers).

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Civitas.Id.Sweden:

Package Downloads
Civitas.Id.Sweden.DataAnnotations

DataAnnotations ValidationAttribute family for Swedish official ID types in string DTOs.

Civitas.Id.Sweden.EntityFrameworkCore

EF Core 10 ValueConverters for the Civitas.Id.Sweden official ID types (personnummer, samordningsnummer, organisationsnummer).

Civitas.Id.Sweden.Json

System.Text.Json source-generated converters for Swedish official ID types. AOT-clean.

Civitas.Id.Sweden.Fakers

Algorithmic fakers for valid Swedish official ID numbers (personnummer, samordningsnummer, organisationsnummer). Default constructor uses cryptographically secure RNG (System.Security.Cryptography.RandomNumberGenerator). Seeded and caller-injected Random overloads exist for deterministic test fixtures; do not rely on them for security-sensitive values.

Civitas.Id.Sweden.Dapper

Dapper 2.x TypeHandlers for the Civitas.Id.Sweden official ID types (personnummer, samordningsnummer, organisationsnummer).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 176 6/20/2026

See CHANGELOG.md for the full release notes.