Having an input from the client-side (browser), I need to perform a transaction on the server-side , on the database to be specific ( business logic ).
Is a good practice to make validations on the user input before making the transaction ? Am I violating the " Single responsibility principle " ?
EDIT: single responsibility principle - my bad, it doesn't make sense here.
Best regards.
There are several reasons why it is absolutely imperative to make validations on the server side, despite the fact that the input may have been checked on the client side:
This is not a violation of single-responsibility principle, because client-side and server-side validations serve different purposes. Client-side validations serve as a visual prompt to the user of what is valid and what is invalid, while server-side validations preserve data consistency.
Is a good practice to make validations on the user input before making the transaction ?
Yes.
If a man comes to your door and says they are the Queen, do you let him in?
Similarly, you should validate server-side - since the data sent from your client (the browser) can't be trusted.
it is crucial to do server side validation, because client side validation can be passed by disabling the JavaScript or by using tools like fiddler or curl, on the other hand if you want to have a have a user friendly app client side validation will be a crucial tool to use.
Jquery validation is a front end library for client side validation
MVC Model Validation can generate both client and server side validation
Remote Attribute is a useful attribute to take a look at your case i think.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.