Yet Another jQuery Validation Plugin (this time with tinyness)
I've used a number of pure JavaScript libraries and jQuery plugins to handle client-side validation over the years but I never really liked any of them. As I often do when I can't find exactly what I want, I built a new one.
There are certainly libraries out there that cover a broader set of features, but my goal here was to make it dirt simple. So simple in fact that anyone should be able to read the source and in a few minutes figure out how to make it conform to novel requirements. The entire framework is shown here in the following gist:
As you can see it takes up just over 100 lines and offers out-of-the-box support for a number of standard validation patterns. However, additional validator methods can be added via the options object. Below is a usage sample that will make things more clear:
In the above example you can see that adding validation to any input element is as simple as defining a "data-validators" attribute to the element. The value of this attribute is essentially a JSON string with some syntactic sugar to make it easier on the eyes. For example, you don't have to surround the whole string with curly braces and if you are defining a validator such as "required" but have no additional options to specify you don't have to do "required:{}" for the JSON to be valid. If you look at the "expandValidatorString" method in the source you can see that these elements are added dynamically before the JSON is evaluated.
At some point I'll put this up as a repository with more complete documentation but I wanted to get it out there for some feedback before that. Let me know what you think.
