by signing a contract that states they must check your items before leaving the building, yes, it can
The law overrides agreements
If he had signed or agreed to their terms (which he didn't) the worst they could do is hold him there if they had a reasonable suspicion he had stolen something.