DEV Community

Business Rules Must Be Enforced by the API

Wissam A on August 15, 2017

An important concept to keep in mind when designing web applications is that business rules must be enforced on the backend, by the API. In this ar...
Collapse
 
asynccrazy profile image
Sumant H Natkar

Asp.Net MVC really provides a clean way to implement these validations on server as well as the client side, and it does with using the DRY principle.

It allows us to use data annotations on the model which can be validators, and they are triggered on both client and server.

Collapse
 
imwiss profile image
Wissam A

That's great, thanks Sumant. I haven't touched ASP.NET in a little while, I'd have to get back into it and play with this.

Collapse
 
rlipscombe profile image
Roger Lipscombe

It's not even about "hacking" the browser. The browser's just doing HTTP (or HTTPS) requests. By using Fiddler (Windows) or Charles Proxy (macOS) or Wireshark, you can see the underlying requests. Then you can replicate the requests (with modifications) by simply using curl or Postman (for Chrome) or whatever.

Collapse
 
imwiss profile image
Wissam A

Absolutely agreed! Those are great tools to understand what's going on in the communication layer. I also often use Postman to fool around with APIs and see how they behave when you try to break them. Thanks for the feedback, Roger.

Collapse
 
ben profile image
Ben Halpern

This is absolutely critical info. I sometimes take for granted how ingrained this is in my mindset when I encounter developers who are not thinking along these lines.

Collapse
 
imwiss profile image
Wissam A

I totally agree, Ben. It's easy to think that everybody knows this stuff but the truth is, we didn't know everything we know now when we started out. Thanks for your feedback.