Any sovereign nation can write whatever it likes into its legal code.
Well, not exactly. In the EU, as you should be aware, the legislative ability of national parliaments is limited by the various EU treaties, which make EU law superior to national legislation in many respects.