The Messenger of Allah ﷺ said, "Fasting is a shield. When one of you is fasting, he should not speak obscenely or behave foolishly. If someone insults him or tries to fight him, let him say, 'I am fasting.'"
حدثنا إسحاق قال حدثنا مالك عن أبي الزناد عن الأعرج
أن رسول الله ﷺ قال إن الصيام جنة فإذا كان أحدكم صائما فلا يرفث ولا يجهل فإن امرؤ شاتمه أو قاتله فليقل إني صائم
Its isnad is sahih, it appeared previously at 7484, and see 9909, Hurairah, that the Messenger of Allah ﷺ said, "Fasting is a shield, so when one of you is fasting, let him not speak obscenely nor act foolishly, and if someone curses him or fights him, let him say, 'I am fasting.'"