Today, we are going to fix this. If you were tasked to build a ColdFusion server-side form validation library, what would it look like? Suppose the following requirements were given and lets see what kind of creativity can be applied.
- The validation library should be able to be dropped into any application and validate any type of form. In other words, there needs to be a clean “language” for specifying things like required fields, field types (text, numeric, postal code, bank account, etc.), error messages, and the like.
- The validation library should be extensible. No matter what kind of functionality is implemented, there will always be a weird validation rule that needs to be created for some application.
- The validation library should be able to support validating an entire form at once vs. validating one field at a time. In other words, the developer should be able to validate the form on submit and redisplay the form with errors, or he/she could use some sort of AJAX call to validate a specific field or fields upon an event.
So, while these requirements are not trivial, this leaves things pretty wide open. If you were tasked with building something like this, how would you do it? I have some ideas, but rather than limit peoples creativity, I want to see what can be come up with first.