GIGO…Garbage In Garbage Out. This is a term that can sometimes be associated with data. Let’s face it, data is the lifeblood of any organization. In today’s marketplace, data analytics and data mining help organizations meet the needs of their clientele. So…that data needs to be protected to the utmost. This is where, as developers, we have a role to play.
Before I address the developer’s role, let’s chat about the database administrator’s (dba) role. It is their role to protect the data at all cost. Most good dba’s take this very seriously…and rightly so. As a developer, I sometimes don’t look at it that way and feel that it is a pain. “I mean, come on…just give me admin rights to the database and do a select asterisk so I can build cool apps!” I have said variations of this at times throughout my career. That quote is probably making dba’s skin crawl. They have a highly important job…let’s make it easier as developers. In comes data validation.
Data Validation Location
Data validation is performed in two main locations…server-side and client-side. I want to speak to the client-side in this post. This is the first line of defense and the easiest location to tend to things. Most data validation involves forms.
Let’s be real here…show of hands…how many of you have filled out a form, say a registration form, and put in bogus information just to get the form filled out and in the door? I thought so. Once that happens, the data is tainted. Developers can help prevent this.
It can go a long way towards data validation when the proper HTML is used to build a form. Let’s say you are asking the end user for a date. HTML5 has a date input type field complete with drop down calendar! I recall building that by hand. That enhancement alone was worth the price of admission for me to HTML5. If the HTML is written with another input type, say a text field, well…you have opened the door to allow the end user to specify any date format they wish…which will lead to errors and possibly a knock on your door from your friendly. neighborhood dba.
Some examples of helpful HTML5 input types are:
So make sure you select the proper HTML5 input types and constraints to make the rest of your validation easier.