Deuteronomy 21:22:23 (NKJV)
22 “If a man has committed a sin deserving of death, and he is put to death, and you hang him on a tree, 23 his body shall not remain overnight on the tree, but you shall surely bury him that day, so that you do not defile the land which the LORD your God is giving you as an inheritance; for he who is hanged is accursed of God.
Also again in Deuteronomy 24 it says
Deuteronomy 24:16 (NKJV)
16 “Fathers shall not be put to death for their children, nor shall children be put to death for their fathers; a person shall be put to death for his own sin.
Therefore would the events of 2 Samuel 21:8-10 have been considered a violation of God's law?
2 Samuel 21:8-10 (NKJV)
8 So the king took Armoni and Mephibosheth, the two sons of Rizpah the daughter of Aiah, whom she bore to Saul, and the five sons of Michal a the daughter of Saul, whom she brought up for Adriel the son of Barzillai the Meholathite; 9 and he delivered them into the hands of the Gibeonites, and they hanged them on the hill before the LORD. So they fell, all seven together, and were put to death in the days of harvest, in the first days, in the beginning of barley harvest. 10 Now Rizpah the daughter of Aiah took sackcloth and spread it for herself on the rock, from the beginning of harvest until the late rains poured on them from heaven. And she did not allow the birds of the air to rest on them by day nor the beasts of the field by night.