Is on the right track since the validation takes place on the server. And there’s nothing wrong with just leaving it there. The only mistake is leaving it alone in the customer.
The user experience can suffer if you wait for the data to be submitted to analyze if something is wrong. At a minimum you should use the power of Angular to at least do checks as the data is being entered or manipulated in the frontend. This is already a huge gain. So having an API that allows point validation and using it is already an advantage.
But let’s face it, calling the server on every input can be an exaggeration. And putting validations already in the client itself can be a simplification and slightly challenges the server, including eliminates the chance of failures at that time, which could prevent the user to continue until the fault is corrected (the network may have had a momentary problem. The experience tends to get even better.
Of course, some validations cannot be done on the client side, they need to access the database or even do something that should be privileged. There is no guarantee of privileges in frontend, Anyone can cheat there.
Some people even cache the database in the client, maybe using Indexed DB or something similar, to prevent the client from making unnecessary requests to the server. Of course you have to analyze if this is the case, if you will use frequently, if there is no problem throwing this data on the client, if the volume compensates, etc. To tell the truth almost always that it pays to do this, it was probably a mistake to use web technology.
So it makes enough sense to make in the customer as well, even if it duplicates efforts.
Phrase: 'Cause it doesn’t make much sense for me to have two places with the same rule., makes sense to be sure of all the problems that can occur in validation. Do the primary check in Angular then repeat in your programming language, because it makes a lot of sense to have Front and Back security in such systems. Of course it can be done in the
BackEnd
(which, in my opinion, is mandatory), but whenFrontEnd
would also be a way to send the information already well formatted and correct to theServer Side
. In the projects I participated are always made the two.– novic