Update validator (and protocol doc)

This is built on all open PRs.

In this PR, I

* update the validator to the latest revision of the protocol document,
* do a bit of validator refactoring,
* add a couple more checks to the validator,
* add more validator tests, and
* add a couple of constraints to the document itself (that I found while checking the validator).