Unless you make it clear that you are writing your Will in contemplation of marriage then marriage will revoke your previous Will.
If your marriage is officially ended by the courts (decree absolute or annulment) your Will is not invalid or void. Your former spouse/civil partner is deemed, for the purposes of the Will, to have died on the date your marriage was officially over.
Any gift your former spouse/civil partner would now go to the reserve beneficiaries. If there are none then the estate would be distributed under the rules of intestacy. This may be entirely different to what you would have wanted.
If your former spouse/civil partner was appointed as an executor then, similarly, that appointment would not take place.
It is best to make a new Will immediately following your divorce. Alternatively, you can make a new Will any time after separation to avoid any issues.
Finally, it is possible to make a declaration within your Will in contemplation of divorce to stop your Will being invalid.