Validating unique habtm?

I have a text box field that I’m using the populate my habtm
relationship between widgets and gadgets. I do not, however, want a
gadget to be linked more than once to a widget. I figure the best way
to do this is using validation in the model, but I’m not sure how I
would go about validation using habtm. How could I achieve this?

Thanks in advance!

Online