I would like to share something on implementing Validations in your Application. Enforcing Validations based on business requirements needs to be clarified in detail with the stakeholder so that the Application Development Team can decide in which layer we can implement this.
The various layers in which the validations can be implemented are the Client Side, Middleware or in the Database side. Each has its own pros and cons. Some Business may need to enforce the same validation in all these places to ensure someone in not pass through these Validations by other ways.
Lets talk with a Case Study :
ABC is a eCommerce site where customers can buy products online and they also have an option to pay through the MyWallet apart from the regular Card transactions.
MyWallet is a feature in which the customer can load some amount from his Creditcard and use them when needed. This was working good and lot of customers have been using this for instant payment through MyWallets. This applicable for all the products which the user is ordering in the site.
ABC Recently announced that the MyWallet feature will not be applicable for all products and it’s allowed only for a specific category. This means the button “Pay from My Wallet” should be shown only for those specific categories which are applicable.
The Project team who are working on the development of this eCommerce web application now need to implement this new change.
Possible Ways :
1.NOT Safe :
Implement this validation in the middleware server before goes to database. OR Add a constraint in the Database side.
1.For any financial, mission critical things always implement the validation in the Sever side. For Simple Form Inputs client side validation will work.
2.Please explain the Risk Involved in Client Side validations to the Clients and Stakeholders and get enough time to address the same.
Thanks for Reading..