The Shulchan Aruch · Orach Chayim
אורח חיים ר״כOrach Chayim 220
Siman 220 of 697 in Orach Chayim — 2 se'ifim
הלכות שאר ברכותLaws of Other Blessings· siman 220
Se’if 1א׳
הָרוֹאֶה חֲלוֹם וְנַפְשׁוֹ עֲגוּמָה, יֵיטִיבֶנּוּ בְּאַפֵּי תְּלָתָא דְּרַחֲמֵי (פי' שֶׁאוֹהֲבִים אוֹתוֹ) לֵיהּ, וְלֵימָא בְּאַפַּיְהוּ: חֶלְמָא טָבָא חַזַּאי, וְלֵימְרוּ אִינְהוּ: טָבָא הוּא וְטָבָא לִיהֲוֵי וְכו'.
Rectifying a dream and fasting about it. Contains two paragraphs. When one has a dream and is anxious about it, one can rectify the dream in front of three people who care about him. He can say to them: "I had a good dream" and they can say to him "it is a good dream and it will be well."
Se’if 2ב׳
יָפָה תַּעֲנִית לְבַטֵּל חֲלוֹם רַע, כְּאֵשׁ לִנְעֹרֶת. הַגָּה: וְדַוְקָא בּוֹ בַּיּוֹם, וַאֲפִלּוּ בְּשַׁבָּת, וְעַיֵּן לְקַמָּן סִימָן רפ"ח.
It is good to fast to nullify a bad dream. Like fire on wood chips. Rem"a: Specifically, this applies to the same day and even on Shabbat.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0