The Prophet ﷺ said, "Fasting is a shield. When one of you is fasting, he should not speak obscenely or behave foolishly. If someone tries to fight him or insult him, let him say, 'I am fasting, I am fasting.'"
حدثنا عبد الله بن مسلمة القعنبي عن مالك عن أبي الزناد عن الأعرج
أن النبي ﷺ قال الصيام جنة إذا كان أحدكم صائما فلا يرفث ولا يجهل فإن امرؤ قاتله أو شاتمه فليقل إني صائم إني صائم
Bukhari narrated it in the Book of Fasting, Chapter on the Merit of Fasting, hadith no. 1894, from Qanabi, in full, and it is found in Muwatta (Yahya): 1/310. Muslim also narrated it, hadith no. 1151, through another route from Abu Zinad.