Add `janitor` to `validate` function.

Now `validate` accepts a janitor function that is invoked if the
function built by `validate` encounters an error.

Closes #263.