I am involved in a web development project using some existing PHP framework. The web app involves taking some user input data from a web form and then save the data, along with some internally generated data, into various tables in a database. As I debug the existing code (of course, the code was not designed by me), I found that the existing code is validating the same input field multiple times. The web form itself has about 10 input fields. But the tracing results show that there are about 250 hits to the StringValidator alone. I have not yet counted the hits on the other validators (such as IntegerValidators, etc.).
All the validations that I am talking about here are at the backend, and the validation rule is the same for the same input field -- that is, the code is now just using the same validation rule multiple times on the same input field. For instance, there is a field by ID "first_name" and the code is validating whether this field is a string 5 or 6 times. I am not talking about validating the same input field with several different validators (for instance, required, string, not containing exotic characters, etc.)
So, what do you think about this kind of practice of coding: good, ok, bad? Or this kind of wasting of PHP execution time is ok?
Thank you very much in advance for your opinion!