ReValidator.Contracts
1.0.1
dotnet add package ReValidator.Contracts --version 1.0.1
NuGet\Install-Package ReValidator.Contracts -Version 1.0.1
<PackageReference Include="ReValidator.Contracts" Version="1.0.1" />
<PackageVersion Include="ReValidator.Contracts" Version="1.0.1" />
<PackageReference Include="ReValidator.Contracts" />
paket add ReValidator.Contracts --version 1.0.1
#r "nuget: ReValidator.Contracts, 1.0.1"
#:package ReValidator.Contracts@1.0.1
#addin nuget:?package=ReValidator.Contracts&version=1.0.1
#tool nuget:?package=ReValidator.Contracts&version=1.0.1
ReValidator
ReValidator provides runtime-reconfigurable validation for .NET applications.
Unlike traditional validation frameworks that rely on static rule definitions or reflection-heavy execution, ReValidator uses compiled expression trees, achieving performance close to statically defined validation rules while preserving full runtime flexibility.
This makes ReValidator well-suited for scenarios where validation rules must be modified without redeploying the application (e.g. configuration-driven systems, rule engines, multi-tenant platforms).
Features
- Runtime configuration of validation rules
- Near-static execution performance using compiled expressions
- No reflection during validation execution
- Standard
IValidator<T>integration - Dependency Injection friendly
- Support for reusable helper methods in expressions
Installation
Install via NuGet:
dotnet add package ReValidator
Or via the NuGet Package Manager:
Install-Package ReValidator
Getting Started
Dependency Injection
Enable ReValidator by registering it in the service container:
services.AddReValidator();
This registers the IValidator<T> interface and all required internal services.
Registering helper methods
If your validation expressions depend on reusable helper methods, you can register them explicitly:
using ReValidator;
services.AddReValidator(options =>
{
options.RegisterType<Helpers>();
});
Registered types become available for use inside validation expressions.
Defining validation rules
Validation rules can be added or updated at runtime:
using ReValidator;
services.ApplyReconfiguration(
new DynamicReconfiguration
{
RuleName = "FullNameRequired",
PropertyName = "Name",
ErrorMessage = "The \"{PropertyName}\" is required",
Expression = "x => !string.IsNullOrWhiteSpace(x.Name)",
FullPathToModel = typeof(Person).FullName
});
Rule properties
| Property | Description |
|---|---|
| RuleName | Unique rule identifier |
| PropertyName | Target model property |
| ErrorMessage | Validation error message |
| Expression | Validation logic as an expression string |
| FullPathToModel | Fully qualified model type name |
Consuming the validator
Inject and use the validator via the standard IValidator<T> interface:
using ReValidator;
public class MyClass
{
private readonly IValidator<Person> _validator;
public MyClass(IValidator<Person> validator)
{
_validator = validator;
}
}
Validation usage
Validate an input model as follows:
var validationResult = validator.Validate(model);
if (!validationResult.IsValid)
{
_logger.LogInformation(
"Validation failed: " +
string.Join("; ",
validationResult.Errors.Select(x =>
$"{x.PropertyName}: {string.Join(", ", x.ErrorMessages)}"))
);
}
Performance considerations
- Validation expressions are compiled once and cached
- No reflection is used during validation execution
- Execution speed is comparable to statically coded validation rules
- Runtime reconfiguration does not require application restart
Limitations
- Validation expressions must be valid C# expressions
- Only members available on the target model and registered helper types can be accessed
- Expression parsing errors surface during configuration, not execution
Packages
ReValidator.Contracts– Shared contracts and abstractionsReValidator– Core validation engine and DI integration
Compatibility
- netstandard 2.1
- ASP.NET Core
- Console applications
- Background services
License
This project is licensed under the MIT License.
Note: ReValidator is a .NET-specific validation library and is not related to JavaScript or JSON Schema validators with similar names.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Linq.Dynamic.Core (>= 1.6.8)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ReValidator.Contracts:
| Package | Downloads |
|---|---|
|
ReValidator
ReValidator provides runtime-reconfigurable validation for .NET applications. Unlike traditional validation frameworks that rely on static rule definitions or reflection-heavy execution, ReValidator uses compiled expression trees, achieving performance close to statically defined validation rules while preserving full runtime flexibility. |
|
|
ReValidator.Validation.MinimalApi
Dynamic, rule-based request validation for ASP.NET Minimal APIs using Endpoint Filters. This package integrates ReValidator into Minimal APIs, allowing request DTOs to be validated using runtime-loaded rules instead of compiled validators or attributes. |
|
|
ReValidator.Validation.Mvc
ReValidator.Validation.Mvc is a lightweight, generic validation adapter for ASP.NET Core MVC, built on top of the ReValidator engine. It allows you to apply strongly-typed, reusable validators to controller parameters using a simple [Validate] attribute, with full support for dependency injection and dynamic rules. |
GitHub repositories
This package is not used by any popular GitHub repositories.