Ruminations from the Long Doctor

Validanguage 0.9.5 Released

September 28th, 2008

I just finished a new 0.9.5 release of Validanguage, available for download on the download page. In addition, I finally brought the documentation up-to-date for the 0.9.4 release, primarily by creating a separate documentation page to list the Advanced Validanguage Features which were added in version 0.9.4.

It seems like my documentation is always running about one release behdind the actual code.  I wish I could say I’m gonna start doing a better job about this, but honestly, I think the docs will always be at least a day or 2 (if not a week) behind the new releases.  However, the API reference at least has been updated for the new 0.9.5 release.

Without further ado, here’s a list of what’s new and different in 0.9.5:

New Internal smartCommaSplit() method

The coolest change to me is that the method used to split up function names which are provided as validations or transformations is now smart enough not to split them on commas appearing inside of the functions.  This means that you can now provide arguments when declaring validation or transformation functions, which makes it much easier to use the validanguage.format() transformation.  For example:

onblur: ”validanguage.format( ’(xxx) xxx-xxxx’, ’()- ’, /^(\\d){3}[ .-]?(\\d){3}[ .-]?(\\d){4}$/ )”

In previous versions of  validanguage, the commas above which are used to separate the arguments would have been treated as if you were listing 2 different functions (ie, onblur=”func1, func2″).  The 0.9.5 version of validanguage counts open parenthesis and open curly braces to know when commas are being used to separate functions and when they are being used inside arguments.  As a result, it is now possible to pass arguments to validations and transformations.

New and Improved validateDate() Function

The validateUSDate() function which I had previously been using was a pretty stupid regex.  It considered “16/99/3942″ to be a valid date.  The new validateDate() method is much better, supporting true date validation, numerous date formats and a number of other options.

Customization of validateDate() is achieved by providing an options object as the second argument to the function.  Because all validanguage validations are called with the text of the object being validated as the first argument, the word “text” must be provided to validateDate() as the first argument when you wish to supply additional arguments. For example, in the comment API, you could specify:

validations=”validateDate( text, { dateOrder: ‘dmy’, twoDigitYearsAllowed: true }”

The validateUSDate() function has been deprecated and is now functionally equivalent to calling validateDate() without any arguments.  Thus, if you are using validateUSDate() you should replace it with validateDate() as the stub validateUSDate() function will be removed in the near future.

For a full list of the supported arguments which you can supply to validateDate(), see the the API reference (the regular docs will be updated to include several examples of using validateDate() shortly).

validateTimestamp() Function

I also added a validateTimestamp() function which can be used to validate timestamp fields.  The new function supports validation of timestamps that include miliseconds and timezones and also supports all the options available for validateDate().  Again, see the the API reference for more details.

Disabling Validation for an Entire Form

You can now easily disable all validations for a given form with the following syntax:

validanguage.el.formId.disabled = true;

Bug Fix for Regex Validation in the Comment API

In all previous versions of validanguage, the regex validations never actually worked under the Comment API.  This is because I was not properly converting regexes declared using the Comment API over to the native Object API.  As of version 0.9.5, regex=”regex_here” now works properly in the Comment API.

Thanks to everyone who’s been using validanguage since it was released 4 months ago and to those users who have provided me with bug reports and feature suggestions.  Please keep the questions and comments coming!

Posted in Code | No Comments »

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

kruger