Modularize validations.

Closes #1