Currently um working in an application and it has the following hierarchy

WEB API2 Controllers (hilds the end points)

Business Logic Layer (Dedicated for business logic handling )

Data Access Layer (Repositories)

If we want to impose a validation which does not related to a business logic as for an example a character count validation for a specific field in an entity , what will be the ideal place to implement it?

Some says it should be on Controller it self , but I cannot agree with it .

  • Who imposes a restriction on the character count if the restriction doesn't come from the business rules/business logic? – Bart van Ingen Schenau Jul 18 '16 at 12:14
  • Some believes business logic should address only business related logic , character count limit is independent from the business logic , it's because of the restrictions imposed by the technology and the users . um in the verge of two dilemma. Some argues a presence of an object module layer might solve the issue and it's been identified as an anti pattern by some experts . I know this sounds wired @BartvanIngenSchenau – Kalanamith Jul 19 '16 at 7:07
up vote 4 down vote accepted

There are no hard and fast rules. But usual place to implement is in the business logic layer. Also I think that field size validations are business logic.

If you use a rich domain model you should implement validation in the entities. But if you don't have a rich domain model and the only interface you provide to the outside world is via your web API I don't think there is anything wrong with doing validations there.

If there is a front-end app I would duplicate the validation logic there as well to give better UX and save the network call.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.