HeroKit.FluentValidation
3.7.0
dotnet add package HeroKit.FluentValidation --version 3.7.0
NuGet\Install-Package HeroKit.FluentValidation -Version 3.7.0
<PackageReference Include="HeroKit.FluentValidation" Version="3.7.0" />
<PackageVersion Include="HeroKit.FluentValidation" Version="3.7.0" />
<PackageReference Include="HeroKit.FluentValidation" />
paket add HeroKit.FluentValidation --version 3.7.0
#r "nuget: HeroKit.FluentValidation, 3.7.0"
#:package HeroKit.FluentValidation@3.7.0
#addin nuget:?package=HeroKit.FluentValidation&version=3.7.0
#tool nuget:?package=HeroKit.FluentValidation&version=3.7.0
HeroKit.FluentValidation
FluentValidation rules for HeroKit: Turkish identity and tax numbers, IBAN, card numbers, e-invoice numbers, MERSİS, barcodes, and phone numbers, postal codes, vehicle plates, national and tax ids of any registered country (Türkiye and the United States are built in).
dotnet add package HeroKit.FluentValidation
Requires FluentValidation 12.0.0 or later.
using FluentValidation;
using HeroKit.FluentValidation;
using HeroKit.Globalization;
public sealed class CustomerValidator : AbstractValidator<Customer>
{
public CustomerValidator()
{
RuleFor(x => x.IdentityNumber).NotEmpty().Tckn();
RuleFor(x => x.TaxId).TaxId(Countries.Turkey);
RuleFor(x => x.Iban).Iban();
RuleFor(x => x.Mobile).PhoneNumber(Countries.Turkey, mobileOnly: true);
RuleFor(x => x.PostalCode).PostalCode(Countries.Turkey);
RuleFor(x => x.Plate).VehiclePlate(Countries.Turkey);
RuleFor(x => x.Card).CardNumber();
RuleFor(x => x.InvoiceNumber).GibInvoiceNumber();
RuleFor(x => x.Mersis).Mersis();
}
}
Safe file uploads (HeroKit.FileTypes): file name, program or script content, content that does not fit the extension, macros, size and allowed types.
using HeroKit.FileTypes;
var imagesOnly = new UploadPolicy { AllowedTypes = [FileTypes.Jpeg, FileTypes.Png], MaxLength = 5 * 1024 * 1024 };
RuleFor(x => x.Photo).NotNull().SafeUpload(f => f.OpenReadStream(), f => f.FileName, imagesOnly); // IFormFile
Null and empty values pass; add NotEmpty() to require a value. Messages use {PropertyName} and can be replaced with WithMessage.
Documentation: https://herokit.lyconiq.com/articles/validation.html
| Product | Versions 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. |
-
net10.0
- FluentValidation (>= 12.0.0)
- HeroKit (>= 3.7.0)
- HeroKit.FileTypes (>= 3.7.0)
-
net8.0
- FluentValidation (>= 12.0.0)
- HeroKit (>= 3.7.0)
- HeroKit.FileTypes (>= 3.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
SafeUpload(openRead, fileName, policy) checks uploaded files of any type with HeroKit.FileTypes. The package now depends on HeroKit.FileTypes. Requires FluentValidation 12.0.0 or later.