The law should be based on anatomy alone, and anyone who presents himself/herself as a different sex, say, in engagement and/or marriage should be charged with committing fraud.
The only exceptions made should be for the very few who are born with the anatomy of both sexes.
I would consider one's genetic code to be part of one's anatomy.