I'm not convinced. I used to have to wear business formal, and it was largely clothes I would not buy but to wear to this job. It felt very much like a uniform.
Does your opinion change if the workers being told to wear a certain dress code are relatively low paid?
A Dress Code and a Uniform may have similarities, but they are not the same.
Broadly, a uniform requires you to wear identical attire to that of your colleague in like employ; where as a dress code establishes an acceptable type of attire or possibly colour.
The standard for an employer having to pay for a 'uniform' is a reasonable one, based at least in part on, this piece of clothing is not something I would wear on my free time; and not something I could wear working for a different employer.
A suit and tie is transferable. Most men would be expected to own at least one for weddings and funerals or a nice dinner date; and if you're working in a type of environment where that would be expected dress code, you likely own at least 2, with multiple dress shirts and ties.
Whereas......if you're told to wear a Tim Horton's ball cap and pullover......I rather hope you're not wearing it on a date, nor should you be wearing if you go to work for McDonalds.
In that latter scenario, the uniform is non-transferable to other uses, therefore the employer should pay.
****
Now, we can have an argument about whether the employer should pay in other contexts........ I have a friend who got hired to work on the top executive floor of a major bank.... Before her first day, in the office, she was taken by a bank staffer to a high end retail outlet where upon the bank credit card was pulled out to buy her 4 women's business suits, 2 dresses, 4 blouses, and 2 pairs of shoes. The bill was eye-watering, more than 2 months pay for her.
So....
That said, retail employers have options to keep uniform costs down, by moving many items into 'dress code' category. Target does/did this by setting a colour requirement for pants, and a general style (business casual); but provided the shirts.
This is a common choice.
An employer could take this further by requiring a dress shirt of 'x' colour and then just having you affix a name tag/ID, or wear a vest over the top etc.
A murky point might be if the employer requested colour is something most people wouldn't be caught dead in on their own time, or wouldn't be suitable to another workplace {transferability)