Add validator architecture.

Fixes #5.