The National Emergencies Act of 1976 provides the statutory basis for a president to declare a national emergency. The law requires that the president identify the provisions that allow him to exercise the power:
SEC. 301. When the President declares a national emergency, no powers or authorities made available by statute for use in the event of an emergency shall be exercised unless and until the President specifies the provisions of law under which he proposes that he, or other officers will act. Such specification may be made either in the declaration of a national emergency, or by one or more contemporaneous or subsequent Executive orders published in the Federal Register and transmitted to the Congress.
This means that the president must identify the statute that allows him to do what he wants to do, which in this case means using money from the defense budget to build the wall.
If Congress disagrees, it can pass a joint resolution, but the president can veto it, and then Congress will have to override the veto. The law provides the mechanism for Congress to challenge the declaration of an emergency. This means that the plain language of the law leaves it to the president and Congress, the elected political branches of government, to determine a national emergency. It means that it is not an issue for the federal courts, because the statute has a clearly written procedure for the elected branches of government to resolve any dispute about whether the president is properly following the National Emergencies Act.