Ends in:
4 DAYS
7 HRS
16 MIN
36 SEC
Ends in:
4 D
7 H
16 M
36 S

FluentValidation Integration

ABP Validation infrastructure is extensible. Volo.Abp.FluentValidation NuGet package extends the validation system to work with the FluentValidation library.

Installation

It is suggested to use the ABP CLI to install this package.

Using the ABP CLI

Open a command line window in the folder of the project (.csproj file) and type the following command:

abp add-package Volo.Abp.FluentValidation

Manual Installation

If you want to manually install;

  1. Add the Volo.Abp.FluentValidation NuGet package to your project:

    Install-Package Volo.Abp.FluentValidation
    
  2. Add the AbpFluentValidationModule to the dependency list of your module:

[DependsOn(
    //...other dependencies
    typeof(AbpFluentValidationModule) //Add the FluentValidation module
    )]
public class YourModule : AbpModule
{
}

Using the FluentValidation

Follow the FluentValidation documentation to create validator classes. Example:

public class CreateUpdateBookDtoValidator : AbstractValidator<CreateUpdateBookDto>
{
    public CreateUpdateBookDtoValidator()
    {
        RuleFor(x => x.Name).Length(3, 10);
        RuleFor(x => x.Price).ExclusiveBetween(0.0f, 999.0f);
    }
}

ABP will automatically find this class and associate with the CreateUpdateBookDto on object validation.

See Also

Contributors


Last updated: January 10, 2020 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

In this document
Community Talks

What’s New with .NET 9 & ABP 9?

21 Nov, 17:00
Online
Watch the Event
Mastering ABP Framework Book
Mastering ABP Framework

This book will help you gain a complete understanding of the framework and modern web application development techniques.

Learn More