1
votes

I have a large enterprise application with specific domain logic and validation with external domain services. Validation layer already implemented in the base system.

My api uses data transfer objects for client-server messaging, but validation in ASP.NET Web Api suggests use Data Annotations attributes or IValidatableObject interface in model classes (or DTO).

How I can integrate my legacy validation system with ASP.NET Web Api validation?

Thanks.

1

1 Answers

0
votes

It sounds like your validation layer, being logic that you have around your domain level objects, doesn't necessarily need to be "integrated" with your web api in the interest of keeping these separate.

For the api validation, you're either going to add another level of validation in your api using the Data Annotations/ModelState solution (or manual validation checks in your controllers) or handle the exceptions that bubble up from your domain validation in your service layer, where you can format and respond appropriately to the consumer.