I have a main calculator project in the namespace 'Calculator.Main
'. It uses different rules for different clients to calculate tax.
-
Suppose I have 2 client
ClientA
andClientB
. -
Each clients demands different rules. So I'll add the validator part into a dll and replace that specific dll after deployment based on each client.
I'm using FluentValidator
.
- The first dll will be in the namespace
Calculator.Validators.ClientA
- The second dll will be in the namespace
Calculator.Validators.ClientB
This is an example of a validator
namespace Calculator.Validators.ClientA
{
public class Validator : AbstractValidator<Modal>
{
public Validator()
{
RuleFor(p => p.FirstName).NotNull().NotEmpty();
RuleFor(p => p.LastName).NotNull();
RuleFor(p => p.Email).EmailAddress();
RuleFor(p => p.Phone).NotNull();
}
}
}
I also have a mapping in database that maps which client need which validator
It's like
ClientA -- Calculator.Validators.ClientA
ClientB -- Calculator.Validators.ClientB
How can I accomplish creating an instance of the validator dynamically?
Aucun commentaire:
Enregistrer un commentaire