0

I have a attribute in a form which the attribute is required. I need this required in all my requests except for one request where because of an exception I don't want the attribute to be not required. Is this even possible? If yes, how can I do it?

Gion Rubitschung
  • 741
  • 11
  • 31

1 Answers1

0
  1. I absolutely agree with Panagiotis Kanavos that you need to use an another DTO object in this case. This would make your code much easier to read for new developer.
  2. You can implement IValidatableObject interface on your DTO object. See example here. This seems very similar to what your are searching for.
  3. Another approach (although, I don't recommend it in this case) is to use some library that do similar validation but you can add some logic in validation. For instance, take a look at FLUENT VALIDATION