Add "validate by" with tests

Closes #31.