validates uniqueness failing oddly

Hey guys

I have this question on stack overflow(I only use it because it’s easier to format the code). is anybody willing to help?

all the best,

Andre