extracting guardValidationError and refactoring