Validanguage and Node.js

It’s been over 2 years since I last updated my Validanguage javascript library. In that time, several interesting trends emerged in the world of Javascript. One of them is the introduction of HTML 5’s form validation support. Without getting into too much detail, I feel that HTML 5’s built-in validation is a good fit for many applications, but other sites will likely still benefit from a more full-featured form validation library. The second and third major trends in the past couple years has been the rise of Node.js and single-page web apps.

Validanguage was designed for the Web 2.0 world: websites that still use standard forms but augment them with occasional ajax requests to fetch supplemental data. In 2014, however, the bleeding edge has shifted to implementing entire sites as a single app within a framework such as Backbone.js, Ember or AngularJS; and, often, doing away with forms entirely.

Tentative Roadmap

  • Add a shitload of unit tests via Node.js/Grunt/Jasmine/PhantomJS. Manual testing of new versions of Validanguage is excruciating and I need to automate this if I’m ever going to make progress on any eventual refactoring.
  • To fit within the context of a Node.js-based single-page web app, validation rules should be defined once (in a model). This model will then expose the validation rules for use on both the server and client. If the validation needs to change, you change it once in the model and both server and client are updated.
  • My vision for future versions of Validanguage is for it to retain its non-reliance on a particular framework. To the extent that it can be easily integrated into existing libraries or frameworks, I’ll see what I can do, but I’m not intending it to ever require Node.js, jQuery, Angular, etc.
  • Currently, Validanguage relies on form tags. I’d like to do away with this reliance and allow validation behavior to be defined on arbitrary “groups” of DOM elements/form controls.
  • Similarly, Validanguage is bound to a form control via DOM ID. I’d like it to support using arbitrary selectors as well.
  • Validanguage should be compatible with asynchronous loading and implemented as an AMD module.

I’m starting with the first two bullet points. You can view my progress on Validanguage’s github page, which is finally seeing some action. I was very fortunate in my choice of JSON and HTML comments as the two methods for defining validation rules in Validanguage. Using Validanguage’s JSON API within a model on the backend (in Node.js) will work out perfectly. Validanguage middleware (installable via npm) can interpret and execute the rules to validate content posted to the server. To implement the rules client-side, custom helpers for Handlebars, Jade and other template languages can export the rules from the model into either script tags or the HTML markup in comment tags, which will play nicely with asynchronous loading. This approach works well in the CakePHP Validanguage helper I’d written years ago.

I’m really excited to see where this takes me. If you have any interest in collaborating with me, please make sure to get in touch. Now that I’m doing all new development against the github project, it should be pretty easy to team up with other interested developers to start moving this forward. As of last night, I have Jasmine installed in the Node project and I’m ready to start grinding out unit tests before getting started on the fun stuff.

Validanguage_—_bash_—_78×22_and_Oracle_VM_VirtualBox_Manager