Right, the "law" specifies that you have to have a valid tourist visa to get married. Plus; they ask for a photocopy of your last entry stamp, so they would notice. Anyway, if you are planning on applying for residency afterwards, I'm pretty sure you need to have time left on you visa. Good luck!