Initial implementation of form validation.

The present implementation is conceptional, I need to write some test
cases to complete the work.