It does not matter if you or I think a particular law is valid.
It is the law that is enforced. Violate that law at your own peril.
"My peril" has nothing to do with whether or not some law is a made up bullsh*t lie.
If your standards of legality are threats of force against those who disagree, then the Nazi laws against the Jews would be valid by this standard.
Power is not the arbiter of truth.