This is true even of things like companies attempting to lay claim on your entire creative output. In most states in the USA court will enforce reasonable work-for-hire terms on work done on company time with company resources, or dealing directly with the company's business while employed with the company -- but any more than that and the contract is at risk of being unenforceable. The term of art in US and Canadian law is "unconscionable" -- the contract is so unreasonable, or was negotiated with such a vast power differential between the parties, that it would be silly and a moral outrage to enforce.
That said, the author of Nginx was sued by his former employer who tried to lay a claim to Nginx itself. So companies can and will pull a fast one -- hire an employment attorney if you are, or are afraid of finding yourself, in this situation.
That said, the author of Nginx was sued by his former employer who tried to lay a claim to Nginx itself. So companies can and will pull a fast one -- hire an employment attorney if you are, or are afraid of finding yourself, in this situation.