Zhomfr.Validation.Rules.Database
0.6.0
dotnet add package Zhomfr.Validation.Rules.Database --version 0.6.0
NuGet\Install-Package Zhomfr.Validation.Rules.Database -Version 0.6.0
<PackageReference Include="Zhomfr.Validation.Rules.Database" Version="0.6.0" />
<PackageVersion Include="Zhomfr.Validation.Rules.Database" Version="0.6.0" />
<PackageReference Include="Zhomfr.Validation.Rules.Database" />
paket add Zhomfr.Validation.Rules.Database --version 0.6.0
#r "nuget: Zhomfr.Validation.Rules.Database, 0.6.0"
#:package Zhomfr.Validation.Rules.Database@0.6.0
#addin nuget:?package=Zhomfr.Validation.Rules.Database&version=0.6.0
#tool nuget:?package=Zhomfr.Validation.Rules.Database&version=0.6.0
Validation Rules for Database
⚠️ Warning: Active Development (< 1.0.0)
Prior to the release of stable version
1.0.0, this library follows SemVer for initial development. This means breaking changes may occur even in minor releases (0.x).We strongly recommend pinning the package version in your
.csprojto avoid unexpected build errors.
A powerful, intuitive collection of custom validation attributes built directly on top of the standard .NET
System.ComponentModel.DataAnnotations infrastructure. Designed to eliminate boilerplate code, this library brings a
rich set of production-ready validation rules—inspired by robust ecosystem standards (like Laravel's validation
features) — allowing you to validate models cleanly using declarative attributes without reinventing the wheel.
Key Features
- Standard DataAnnotations Integration: Seamlessly works with ASP.NET Core, Entity Framework, and standard
Validatormethods out of the box. - Rich Set of Built-in Rules: Covers frequent validation scenarios that are missing from standard .NET, preventing you from writing repetitive custom validators over and over again.
- Intuitive Declarative Syntax: Clean and expressive attributes to keep your domain models and DTOs readable and maintainable.
- Customizable Error Messages: Fully supports localized and custom error message templates via standard
ErrorMessageproperties.
📦 Installation
Install package:
dotnet add package Zhomfr.Validation.Rules.Database
After add namespace in using section:
using Zhomfr.Validation.Rules.Database;
Available Methods
<table> <tr valign="top"> <td>
</td> </tr> </table>
🛠️ Features and Examples
Exist
Validates that a record with the specified property value exists in the database. Supports any entity type and property that can be resolved via .
public class StubModel
{
[Exist<StubDbContext,StubEntity>(nameof(StubEntity.Name))]
public string Name { get; set; } = "user@example.com";
}
Unique
Validates that the value is unique within the specified database table and column. This rule fails if a record with the same property value already exists.
public class StubModel
{
[Unique<StubDbContext,StubEntity>(nameof(StubEntity.Name))]
public string Name { get; set; } = "user@example.com";
}
| 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
- Microsoft.EntityFrameworkCore (>= 10.0.13)
- Zhomfr.Validation.Rules.Abstractions (>= 0.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.