Validanguage Version 0.9.6 Released
I completed my final updates and testing to Validanguage version 0.9.6 last night. The impetus for this most recent release was my creation of a CakePHP helper for Validanguage, which I will post on my site for download shortly. If you're familiar with the MVC pattern for Web Applications, I wanted to create a CakePHP helper that would automatically translate the data validation rules present in one or more models into Validanguage API Comment tags to be printed in the view. Thus, data validation needs to be specified only once in the model and is automatically translated into client-side javascript code without any additional work.
In order to implement this without any loss of functionality, I had to make a couple enhancements to Validanguage in this most recent release. If anyone is using Ruby on Rails, .Net or any other MVC Web frameworks with Validanguage, I would love it if they can provide me with similar helper files for additional Web frameworks. I see this as a great way to get more people using Validanguage.
Another way I hope to increase adoption of my library is by adding optional support for javascript frameworks other than Prototype/Scriptaculous. A couple people have requested jQuery and Mootools integration, so that is definitely on my radar.
Also, a huge priority for me is to improve my documentation. I think the API Reference page is pretty sweet, but I definitely want to better integrate my existing Test Cases with my documentation and write some of the docs that are still missing for features added in 0.9.5 and 0.9.6.
Anyway, here's a detailed explanation of what's contained in the 0.9.6 release:
- New validations: validateCreditCard, validateIP, validateUSSSN, validateUSZipCode. The Credit Card validation runs a luhn checksum test to weed out fraudulent card numbers. See the API Reference page for usage details.
- New transformation: validanguage.toggle(). This function is intended for somewhat advanced users, as the object-based syntax for defining this is fairly complex. I haven't yet had time to write any documentation on this, but I did add a new validanguage.toggle() test case page which shows validanguage.toggle() in action. This transformation function is actually 3 functions in one:
- Toggle Visibility: You can use validanguage.toggle() to hide and show other form fields or HTML elements based on the user changing a SELECT box or checking/unchecking a field. As an added bonus, form fields contained inside a region being hidden/shown are automatically disabled/enabled to ensure that validation is correctly handled on fields which are only shown under certain conditions. Also, any toggle visibility statements are automatically called on document.onload to ensure that the state of the UI will always match your declared rules.
- Toggle Values: Allows you to set a value of form field B in response to changes in form field A. This allows you to set a hidden field to 0 or 1 based on whether or not a checkbox has been checked.
- Dynamic Select Boxes: You can add/remove options to select box B in response to what a user chooses for Select Box A. The validanguage.toggle() test case page shows an example of setting up 3 dynamic select boxes which work in conjunction with toggling the visibility of each and the easy enabling/disabling of any associated validations.
- Added optional args to validateMinlength, validateMaxlength, validateRequired and validateRegex to let them be called directly instead of via the minlength="4", required="true", etc. shortcuts. This change was needed for the CakePHP Validanguage helper.
- Added support for .passedField and .failedField classNames. I removed the code in the default showError() function which changed a failed text field's background color to red. I replaced this with code which changes the class name on any fields which failed validations to include "failedField" (and the inverse for "passedField"). Existing class names are preserved; for example, a form field with a class of "styledTextarea" would become "styledTextarea failedField" following validation failure.
- Transformations are now always called prior to validations. Previously, they would either be called before validation or after, depending on your browser.
- API Change: validateAllFieldsOnSubmit setting renamed validateAllFieldsOnsubmit. After being screwed over time and time again by dojo's API musical chairs, it pains me to make this change, but the capitalization was inconsistent with everywhere else in the code.
- Bug fix: transformations defined with transformations="" in Comment API now work correctly.
- Bug fix: multiple validations in one string now all get called correctly.
- Bug fix: support for carriage returns inside functions in Comment API now work correctly. Previously functions defined with carriage returns in them wouldn't execute.
- Bug fix: Comments with transformations no longer overwritten by comments with validations.
That's it for this release. Head on over to the download page to snag yourself a copy.
Posted in Uncategorized | No Comments »
