4 ms·
They are separate. Yes, the UI and the service both validate the data, but they do it for different reasons. One is concerned with the user experience, and the
by steverb 16y ago
They are separate. Yes, the UI and the service both validate the data, but they do it for different reasons. One is concerned with the user experience, and the other is concerned with data validity. There may be some functional duplication there, but they are separate concerns.
The service validates to make sure that the data it is dealing with is safe and isn't going to corrupt something.
The UI validates input to make sure that the service won't reject it so that the user doesn't have to deal with inconvenience of making a round trip to the server, or having to remember what a valid value for a field is.
If you're not feeling up to making things easy for your users you can always throw all the data at the service and wait for it to tell you why the data is invalid. You don't HAVE to validate the data twice.
- jamesgeck0 16y agoAs a user interface shishya, I agree completely. As a developer, I still have to write code that validates the data twice and possibly deal with validation failures in two different ways. Further, I have to make sure that both checks are using the same criteria for validation and keep them in sync if requirements change. This seems less than ideal.