I'm pretty sure Equality Act 2010 makes any such term in a contract unenforceable.
I'm in the UK and I've never had a contract with such a clause in the nearly thirty years I've been working as a developer.
Maybe it's sector dependent I've mostly worked in financial services, would be good to find out what the wider picture is I'm thinking my view is skewed now!
They might be in the contracts, but as far as I know they are invalid or at least restricted by anti-discrimination laws.