segmentio/validate-form — pull request #9 by slajax (2014-02-20 20:09:39+00:00)
Title: options, ability to validate on empty, async validation of entire form

As per a brief [exchange](https://twitter.com/slajax/status/436210173946781696) with @ianstormtaylor on twitter, I was looking for a way to have validate-form async validate all forms when a user clicks submit.

The need for this behaviour was mostly emphasized by the assumption that empty inputs shouldn't be validated on blur. This was resulting in a user experience that required users to do a lot of back and forth to validate a long form as empty or missed inputs don't get validated on blur whatsoever.

I optimized a few things for these situations:

- Added `set(opts)` method to allow for behaviour modifications without affecting compatibility. Example:
```javascript
validate
.set('validateEmpty', true)
.field('input')
..is(...)

validate
.set({ validateEmpty: true});
.field('input')
.is(...)
```
This should allow for more options to be added fairly easily.

- Added `validateAll(fn)` so that onclick of a form you can validate all the form fields and receive back the complete state of the form along with each field's individual state, then XHR should you need to.

```javascript
form.validateAll(function(err, valid, fields) {
if(!valid) return doError()
else sendXHR();
});
```
I felt this approach would be best since it doesn't affect compatibility but provides the desired result as new functionality. There was one wait test that seems to be failing, but I believe it already was. Let me know if there is anything you'd like to see different.

Thanks for this repo, I really like it.