The Messenger of Allah ﷺ said, "Every divorce is valid except the divorce of one who has lost his reason and is overcome in his mind."
حدثنا محمد بن عبد الأعلى الصنعاني أنبأنا مروان بن معاوية الفزاري عن عطاء بن عجلان عن عكرمة بن خالد المخزومي
قال رسول الله ﷺ كل طلاق جائز إلا طلاق المعتوه المغلوب على عقله
No references are available.
[Its isnad is extremely daif] Ibn Jundi related it in Ilal Mutanahiya, 2/156, hadith 1069, from the hadith of Tirmidhi, through the same chain. Ataa bin Ajlan is discarded (matruk), rather Ibn Main, Fallas, and others outright accused him of lying. See Taqrib and others.