I've always wondered about this.
In my contract, it says there is a few months' notice period, both when I want to stop working there as well as when they want me to stop working there. When reviewing the contract, it sounded reasonable and I just assumed that when I get the notice, that's how it is.
Later, I learned of these "there must be a valid reason" type of protections.
Does that make this whole clause void? Or even working in my favor, that is: even if there is a valid reason, our contract adds those months of notice period?