changed validate functions to return a value and throw exceptions otherwise