-
Notifications
You must be signed in to change notification settings - Fork 33
IbanNet.FluentValidation
skwasjer edited this page Feb 7, 2020
·
10 revisions
The IbanNet.FluentValidation
package provides FluentValidation support to validate IBAN user input.
Assuming we have a string
property for the IBAN.
public class InputModel
{
public string BackAccountNumber { get; set; }
}
using FluentValidation;
using IbanNet;
using IbanNet.FluentValidation;
public class InputModelValidator : AbstractValidator<InputModel>
{
public InputModelValidator(IIbanValidator ibanValidator)
{
RuleFor(x => x.BankAccountNumber).Iban(ibanValidator);
}
}
- Register IbanNet
- Register validator
- Register FluentValidation
services.AddIbanNet();
services.AddTransient<IValidator<InputModel>, InputModelValidator>()
services.AddFluentValidation();