Factor out common path validation