-2

I need to make two different validations to the same class in a C# project using fluent validation, how can I do it in a unique validation.

For example:

I have the Example class called ExampleDTO.cs and also I have the ExampleDTOValidator.cs, so I need to implement a validation that in one case do one validation and in the other case use other validation.

Liam
  • 27,717
  • 28
  • 128
  • 190
  • Welcome to SO. I'd recommend taking [the tour](https://stackoverflow.com/tour) and then reading [How to Ask](https://stackoverflow.com/help/how-to-ask) and [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) as an introduction to how SO works, and how to effectively ask a question. – Markus Deibel Nov 12 '19 at 11:41

1 Answers1

0

You can use a if statement:

if(YOUR DECISION IN HERE){
   exampleDTO.ValidateInExampleDTOValidator();
}
else{
   exampleDTO.ValidateInOtherValidator();
}

So you only have to write an other Validation Class.

probst
  • 196
  • 1
  • 1
  • 12