Skip to content

Super Simplify validation Minimal APIs in ASP.NET Core 7 or later with Short-circuit endpoint executions.

License

Notifications You must be signed in to change notification settings

thisisnabi/Endpoints.FluentValidation

Repository files navigation

Endpoints.FluentValidation

Super Simplify validation Minimal APIs in ASP.NET Core 7 or later with Short-circuit endpoint executions.

It's an extension for FluentValidation Package

First create your Dto and validator

public sealed class CreateProductDto
{
    public string Title { get; set; }
}

public class CreateProductValidator : AbstractValidator<CreateProductDto>
{
    public CreateProductValidator()
    {
        RuleFor(x => x.Title)
            .NotEmpty();
    }
}

Second configure validation service

builder.Services.AddScoped<IValidator<CreateProductDto>,CreateProductValidator>();

Finally validate your endpoints

app.MapPost("/products/create", async (CreateProductDto product) =>
{
    // code command execution
}).Validator<CreateProductDto>();

About

Super Simplify validation Minimal APIs in ASP.NET Core 7 or later with Short-circuit endpoint executions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages