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
<PackageReference Include="Civitas.Id.Sweden" Version="1.0.0" />
<PackageVersion Include="Civitas.Id.Sweden" Version="1.0.0" />
<PackageReference Include="Civitas.Id.Sweden" />
paket add Civitas.Id.Sweden --version 1.0.0
#r "nuget: Civitas.Id.Sweden, 1.0.0"
#:package Civitas.Id.Sweden@1.0.0
#addin nuget:?package=Civitas.Id.Sweden&version=1.0.0
#tool nuget:?package=Civitas.Id.Sweden&version=1.0.0
Civitas.Id.Sweden
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 | Versions 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. |
-
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.