Translation for 12:24

وَلَقَدۡ هَمَّتۡ بِهِۦۖ وَهَمَّ بِهَا لَوۡلَآ أَن رَّءَا بُرۡهَٰنَ رَبِّهِۦۚ كَذَٰلِكَ لِنَصۡرِفَ عَنۡهُ ٱلسُّوٓءَ وَٱلۡفَحۡشَآءَۚ إِنَّهُۥ مِنۡ عِبَادِنَا ٱلۡمُخۡلَصِينَ ٢٤
She advanced towards him, and he would have done likewise, had he not seen a sign from his Lord.1 This is how We kept evil and indecency away from him, for he was truly one of Our chosen servants.

Foot notes

221983
Joseph (ﷺ) received warning against fornication either through divine inspiration or a vision of his father.