Extracted a macro to remove common validation.