1 John 2:28-29
28 And now, little children, abide in him; that, when he shall appear, we may have confidence, and not be ashamed before him at his coming.
29 If ye know that he is righteous, ye know that every one that doeth righteousness is born of him.
The Grace New Testament Commentary - 1 John 2:29
2:29 Possibly the Revisionists (being warned against) maintained that God's nature includes both light and darkness (cf. 1 John 1:5). On this understanding, God by His very nature had experience with both good and evil. An obvious deduction from this is that His children could do the same. In contrast, since God is righteous, [then] everyone who practices (lit., "does") righteousness is born of Him. This is the first reference in the epistle to the new birth. The born-again person can be recognized as such if he manifests Christian righteousness. The "commandments" of Christ (cf. the plural in 1 John 3:22) can be summarized under a single commandment: "And this is His commandment: that we should believe on the name of His Son Jesus Christ and love one another, as He gave us commandment" (1 John 3:23). True righteousness is impossible apart from faith in Christ and love for fellow Christians.
John is not talking about how one can decide if a person is regenerate. John is clearly concerned with the deduction one can make if a person knows that God is righteous. If that is known, it follows that one who reproduces His righteous nature is actually manifesting that nature and can rightly be perceived as born of Him.