Legalism: strict adherence, or the principle of strict adherence, to law or prescription, especially to the letter rather than the spirit.
Example:
[
Mat 23:23 NKJV] 23 "Woe to you, scribes and Pharisees, hypocrites! For you pay tithe of mint and anise and cummin, and have neglected the weightier [matters] of the law: justice and mercy and faith. These you ought to have done, without leaving the others undone.