Actually, it would be better to add the following to the top of the function:

```
if (!$form) {
  throw new Error(...)
}

// Make sure form is a jquery object with validate() on it
$form = $($form);
```