Annie
Good question, I asked myself the same thing in many cases. Here is what I ended up (so far).
The cleanest (but tedious) approach is to invoke validation logic in both layers. A pragmatic approach may be to only link to a website (for example, to your controllers).
I think there is no answer that ends all discussions. I think it depends on the context of your project. If the size of the project is modest (from the point of view of people and the size of the code base), and you are sure that not many of the codes will be developed by others that refer to your services API (to the extent that you cannot control), then check at the web level may be enough.
However, if you expect that many customers may need higher level security. When I talk about security here, I find it as a level of consistency - the guarantees you need. If this level is high, there is no way around it: you will need to do this both in the service (to ensure security) and in the web level (mainly to provide end users with an acceptable experience).
So the key driver here is security and how much you really need it. If you need a lot, you go for a "purist" approach. If your application does not exactly make decisions regarding issues of life and death, you go for a pragmatic approach.
Hans westerbeek
source share