How can I cleanly share a Custom Validator (ValidationAttribute) for a data model, a ViewModel, and a DTO in ASP.NET
I’m doing a ASP.NET MVC course. I’m building a REST Web API using ASP.NET WebAPI 2. The application also contains standard MVC 5 views. I’m using DTOs (Data Transfer Objects) to decouple the API from the data model. I’ve made a custom ValidationAttribute that I have applied to a property in my data model, and I’d like to use the same Validation attribute for a property on my DTO as well as a property ViewModel used in an MVC view.