Sayyiduna Abu Dharr (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "When a person does not have anything in front of him equal to the back part of a saddle, his prayer is broken by the passing of a donkey, a black dog, or a woman." The narrator said: I asked Sayyiduna Abu Dharr (may Allah be pleased with him): What about a red or yellow dog? He said: Just as you have asked me, I also asked the Messenger of Allah (peace and blessings be upon him), and he said: "Because the black dog is a devil."
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1452
From this hadith, it is understood that if there is no sutrah (barrier) in front, and a donkey, a black dog, or a woman passes by, the prayer is invalidated.
Some scholars have said: a defect occurs in the prayer, and if a sutrah is present and any of these pass in front of it, then there will be no defect in the prayer.