Both of them, it says, were righteous in the sight of God. Both righteous in the sight of God: and what about the passage that says "No living person will be counted righteous in your sight"? Perhaps in the sight of human beings one may be thought to be righteous, since human beings, as aware as they are of the sins of the body, are equally unaware of the vices of the mind. But in God's sight, before whom the secrets of the heart are laid bare, by whom hidden thoughts do not go unnoticed, who is judged innocent and righteous?
Is there a human being who does not sin in his heart, who does not have a bad thought, who is not guilty of harboring doubts, who does not incur blame through fear? Moses doubts, Aaron goes astray, Peter denies; so who is righteous? And how were they both righteous in the sight of God? In the sight of God, yes, but by means of God. Both righteous in the sight of God, not by their effort but by grace.
Listen to the Apostle: "They are justified gratuitously through the grace of Christ." And again, "Not from ourselves; it is God's gift. Not of works, lest anyone boast." Yet again: "What do you have that you have not received; but if you received it, why do you boast as if you did not receive it?" Therefore, this is more or less what the evangelist is saying: not that they did not have it, but that they received it; not that it was earned, but that it was bestowed. -- St. Peter Chrysologus, Sermon 91 par. 3 [On Zechariah]