If religious doctrine governing the affairs of a corporation organized primarily for religious purposes is inconsistent with the provisions of chapters 24 through 40 of this title on the same subject, the religious doctrine shall control to the extent required by the Constitution of the United States or the constitution of this state or both.