Is there a way I can get my deposit back if my boyfriend and I separate

I am buying a property jointly with my boyfriend. I have a large deposit to put down on the purchase. Is there a way I can get my deposit back if my boyfriend and I separate? Whenever you buy a property jointly with another person you should consider whether there should be a separate declaration …