In our application we have various layers. Service Layer, DAO layer and actions (struts applications).
Data gets passed from one layer to another layer.
Where we should ideally put input validation ?
Say, userid, phone number is coming from UI, They are mandatory. So we are already doing validation at client side.
Now, As per my opinion, Thts all u need. No where else it should be validated.
But one of my colleague argues, what if client makes request directly. So we need to add in Actions also.
Now, At Dao as well, same method is getting used at some other action and tht does not have validation,
Or, Say service layer, It might be exposed as , say as web service, So there also u shd have validation.
So essentially, He is suggesting..we shd have validations everywhere. Which does not make sense for me. Its duplication across layer.
What is ideal approach for this ? Say validation is of may be simple null check or some complex validation.