Added error clauses and messages when validation failed.