segmentio / validate-form

Easily validate a form element against a set of rules.
43 stars 6 forks source link

Remove next-tick dependency #14

Closed johntron closed 4 years ago

johntron commented 9 years ago

The segmentio/validator dependency is an old version which still uses next-tick. This version prevented simple use cases where .validate() is used synchronously, so I've updated to the latest. I realize it's easy enough to add async validators and break this use case, but it's still convenient.

Here's a simple use case:

function is_valid_email() {
  success = false;
  email_validator.validate(function (err, is_valid, reason) {
    if (!err && is_valid) {
      success = true;
    }
  }); // Looks async, but everything is synchronous
  return success;
}