أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسلم وَهَبَ لِعَلِيٍّ غُلَامًا فَقَالَ: «لَا تَضْرِبْهُ فَإِنِّي نُهِيتُ عَنْ ضَرْبِ أَهْلِ الصَّلَاةِ وَقَدْ رَأَيْتُهُ يُصَلِّي» . هَذَا لفظ المصابيح

Abu Umama told that God’s Messenger gave ‘Ali a youth and said, “Do not beat him, for I have been prohibited from beating people who observe the prayer, and I have seen him praying.”

This is the wording in al-Masabih.