HeroKit 3.6.0

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

HeroKit

NuGet NuGet downloads Build & Test Coverage OpenSSF Scorecard License: MIT

Türkçe: README.TR.md · Documentation: herokit.emreakdemir.dev

Everyday extension methods for .NET, with first-class support for Turkish data: TCKN, VKN, IBAN, phone numbers, plates, regions, public holidays and amounts in words. Country rules follow one model (Country, Language, Currency), so new countries can be added without new methods.

dotnet add package HeroKit

Targets .NET 8 and .NET 10. No dependencies. Nullable-annotated and Native AOT ready.

Countries and languages

using HeroKit.Banking;
using HeroKit.Globalization;
using HeroKit.Globalization.Turkey;

"10000000146".IsValidTckn();                                   // true  (T.C. Kimlik No)
"4840847211".IsValidVkn();                                     // true  (Vergi Kimlik No)
"TR330006100519786457841326".FormatIban();                     // "TR33 0006 1005 1978 6457 8413 26"
"TR78 0006 2000 0000 0006 2950 05".GetBank()?.Name;            // "Türkiye Garanti Bankası A.Ş."
"0532 123 45 67".ToE164(Countries.Turkey);                     // "+905321234567"
"34abc123".FormatVehiclePlate(Countries.Turkey);               // "34 ABC 123"
Countries.Turkey.FindRegion("34")?.Name;                       // "İstanbul"
"34710".IsValidPostalCode(Countries.Turkey);                   // true
123.50m.ToCurrencyWords(Currencies.TurkishLira);               // "yüz yirmi üç Türk lirası elli kuruş"
1234.5m.ToCurrencyString(Currencies.TurkishLira);              // "₺1.234,50"
"₺1.234,56".ToAmount(Currencies.TurkishLira);                  // 1234.56
"10000000146".MaskMiddle(2, 2);                                // "10*******46" (KVKK)
Countries.Turkey.FindDistrict("istanbul", "kadikoy")?.Name;    // "Kadıköy" (973 ilçe)
Tckn.Parse("10000000146").ToMaskedString();                   // validated value type: "10*******46"
"istanbul ılıca".ToTitleCase(Languages.Turkish);               // "İstanbul Ilıca"
new DateOnly(2026, 3, 19).AddBusinessDays(1, Countries.Turkey); // 2026-03-23 (skips the bayram and the weekend)
"ABC2026000000001".IsValidGibInvoiceNumber();                  // true  (e-Fatura / e-Arşiv)

Every method takes a Country, Language or Currency. Türkiye and the United States are built in (Countries.UnitedStates: NANP phone numbers, ZIP codes, SSN/EIN, federal holidays, states, Currencies.USDollar, Languages.English). To support another country, implement the rule interfaces and call Countries.Register(new Country(...) { PhoneNumbers = ... }): no new methods are needed. Turkish sorting also works without ICU: names.OrderBy(n => n, Languages.Turkish.TextRules!.Comparer).

Form validation

using HeroKit.Validation;

public sealed class Customer
{
    [Required, Tckn] public string? IdentityNumber { get; set; }
    [Iban] public string? Iban { get; set; }
    [PhoneNumber("TR", MobileOnly = true)] public string? Mobile { get; set; }
    [VehiclePlate("TR")] public string? Plate { get; set; }
}

Also: [Vkn], [TaxId("TR")], [NationalId("TR")], [PostalCode("TR")], [GibInvoiceNumber], [Ettn], [CardNumber]. They work with ASP.NET Core, Blazor and Validator.

Using FluentValidation? Add HeroKit.FluentValidation: RuleFor(x => x.IdentityNumber).Tckn();

File types and uploads

HeroKit.FileTypes is a separate, dependency-free package: content detection for about 70 types (Office inside ZIP, HEIC/AVIF/MP4 brands, WebP, JPEG XL), extension and MIME mapping, and an OWASP-style upload check.

using HeroKit.FileTypes;

FileTypes.Detect(stream)?.MimeType;               // "image/png"
FileTypes.GetMimeType("report.docx");             // "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
FileTypes.CheckUpload(stream, "photo.php.jpg").Rejection; // UploadRejection.DoubleExtension

A runnable ASP.NET Core sample with uploads, Tckn binding and districts: samples/HeroKit.Samples.WebApi.

Conversions

Every conversion has a lenient form that returns a default value and a Try form. Neither throws for bad input. Parsing is culture-invariant unless you pass a provider.

using HeroKit.Strings;

"42".ToInt();                       // 42
"abc".ToInt(-1);                    // -1
"2026-03-07".To<DateOnly>();        // any IParsable<T>
"42".TryTo(out int number);         // true
"1.234,56".ToDecimal();             // 1234.56
"Friday".ToEnum<DayOfWeek>();       // DayOfWeek.Friday

More

Area Examples
Strings ToSlug, Truncate, Mask, Left/Right, RemoveWhitespace, ToTitleCase(culture)
Collections IsNullOrEmpty, WhereIf and Page (also on IQueryable), ToReadOnlyList
Dates StartOfWeek, EndOfMonth, IsWeekend, IsBetween, Age (DateTime and DateOnly)
Prices RoundToStep, ToPsychologicalPrice, IncludeVat, ExcludeVat
Cards IsValidCardNumber (Luhn), GetCardBrand (incl. Troy)
Enums GetDescription, ToEnum, ToUnderlying<T>

The guides and API reference cover every method. Upgrading from 1.x or 2.x? See the upgrade guide.

Questions and contributions

License

MIT

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 was computed.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on HeroKit:

Package Downloads
HeroKit.FluentValidation

FluentValidation rules for HeroKit: Turkish identity and tax numbers, IBAN, Turkish phone numbers, postal codes, vehicle plates and card numbers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.0 0 10/19/2026
3.5.0 52 10/16/2026
3.4.0 49 10/16/2026
3.3.0 45 10/16/2026
3.2.0 45 10/15/2026
3.1.0 41 10/15/2026
3.0.0 47 10/15/2026
1.0.0 71 10/15/2026
1.0.0-alpha.6 220 4/5/2024
1.0.0-alpha.4 290 12/17/2023
1.0.0-alpha.3 220 10/10/2023
1.0.0-alpha.2 248 8/21/2023
Loading failed

No API changes in HeroKit; released with HeroKit.FileTypes 3.6.0. The repository moved to github.com/Lyconiq/HeroKit; releases now carry an SBOM and a build provenance attestation.