Answering the question: Was a Valvert relationship possible to maintain in canon-era France without legal consequences? The answer is yes and no. It depends.
In contrast to Britain, the German states, and the Habsburg Empire, consensual sexual acts between adult men in France were legally tolerated thanks to the Code Napol茅on. Since 1805, as long as men confined their sexual relations to private environments, it was not a criminal offence. However, local authorities made sure to criminalize sexual acts performed in public places, as well as male prostitution. (Because of this partly tolerant attitude towards homosexual relations, France was a suitable place of exile for men like Oscar Wilde.)
So, if your Valjean and Javert do whatever they do behind closed doors at home (and probably even in Madeleine鈥檚 office), they can do so without any legal consequences. What is even better, Javert鈥檚 feelings won鈥檛 be hurt, as he is not transgressing the lawr. But as soon as they move into public territory, they are in trouble, and Javert automatically becomes a criminal鈥擨 am sure he won鈥檛 like it.