Matthew doesn’t tell us how or when Joseph discovered that Mary was pregnant. Still, it must have been shocking news resulting in many sleepless nights as he wrestled with his love for Mary on one hand, and the letter of law on the other hand, which said he could make a public example of her and humiliate her for what appeared to be her unfaithfulness. Verse 20 says that as Joseph was wrestling with his emotions and the decisions he had to make, he had a dream.
Joseph heard the Lord in three dreams and the wise men heard God in their dream. As a result, Jesus our Savior was born, lived, and gave Himself as the sacrifice for our sins. He has earned the right to have our attention, our worship, and our obedience. Dream to believe that God has a plan for your life and if you hear Him, He will do exceedingly, abundantly, more than you can ask or think.