Bondarukini.Validator
10.0.0
dotnet add package Bondarukini.Validator --version 10.0.0
NuGet\Install-Package Bondarukini.Validator -Version 10.0.0
<PackageReference Include="Bondarukini.Validator" Version="10.0.0" />
<PackageVersion Include="Bondarukini.Validator" Version="10.0.0" />
<PackageReference Include="Bondarukini.Validator" />
paket add Bondarukini.Validator --version 10.0.0
#r "nuget: Bondarukini.Validator, 10.0.0"
#:package Bondarukini.Validator@10.0.0
#addin nuget:?package=Bondarukini.Validator&version=10.0.0
#tool nuget:?package=Bondarukini.Validator&version=10.0.0
Bondarukini.Validator
A lightweight, dependency-free validation library for .NET, inspired by FluentValidation.
Provides a simple, fluent API for defining and running validation rules.
β¨ Features
Fluent, chainable syntax
RuleFor(x => x.Name) .NotEmpty() .MinimumLength(3) .WithMessage("Name must be at least 3 characters long.");Built-in rule set
NotEmpty()MinimumLength(int)GreaterThan(IComparable)GreaterThanOrEqualTo(IComparable)LessThan(IComparable)LessThanOrEqualTo(IComparable)
Supports both synchronous and asynchronous validation
Works perfectly with
Bondarukini.Mediatorpipeline behaviorsProvides a
ValidationContextfor additional runtime data
π Installation
dotnet add package Bondarukini.Validator
π‘ Example Usage
using Bondarukini.Validator;
using Bondarukini.Validator.Results;
public class CreateProductCommand
{
public string Name { get; set; } = "";
public decimal Price { get; set; }
}
public class CreateProductCommandValidator : ValidatorBase<CreateProductCommand>
{
public CreateProductCommandValidator()
{
RuleFor(x => x.Name)
.NotEmpty()
.MinimumLength(3)
.WithMessage("Product name must be at least 3 characters long.");
RuleFor(x => x.Price)
.GreaterThan(0)
.WithMessage("Price must be greater than zero.");
}
// Example of custom async validation
public override async Task<ValidationResult> ValidateAsync(CreateProductCommand instance, CancellationToken ct = default)
{
var result = base.Validate(instance);
await Task.Delay(10); // simulate async logic
if (instance.Name == "Forbidden")
result.Errors.Add(new ValidationFailure(nameof(instance.Name), "This product name is not allowed."));
return result;
}
}
π§± Integration
To automatically execute validators inside your request pipeline, use
ValidatorBehaviour<TRequest, TResponse> from Bondarukini.Mediator.Behaviors:
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehaviour<,>));
π¦ Related Packages
| Package | Description |
|---|---|
| Bondarukini.Mediator | Core Mediator implementation |
| Bondarukini.Mediator.Behaviors | Validation & Transaction pipeline behaviors |
| Bondarukini.Mediator.DependencyInjection | Auto-registration for Mediator & Validators |
π§βπ» Author
Yurii Bondaruk
Clean, extensible, and minimalistic architecture tools for .NET πΊπ¦
| 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 (2)
Showing the top 2 NuGet packages that depend on Bondarukini.Validator:
| Package | Downloads |
|---|---|
|
Bondarukini.Mediator
Lightweight Mediator pattern implementation for .NET with no dependencies. |
|
|
Bondarukini.Validation.DependencyInjection
Lightweight Mediator pattern implementation for .NET with no dependencies. |
GitHub repositories
This package is not used by any popular GitHub repositories.