validate fields and test errors