War Caster feat:
When a hostile creature's movement provokes an opportunity attack from you, you can use your reaction to cast a spell at the creature, rather than making the opportunity attack.
There are no requirements for how an OA is triggered in this rule, just that one is. Given that anAs long as the OA is triggered by a hostile enemy's movement you can cast a spell with your reaction instead. This is confirmed by Jeremy Crawford's ruling here.
Thus in your example in the question, a spell casting creature with the War Caster feat a whip and a dagger can cast a spell at someone moving and leaving their 10' reach with the whip, and their 5' reach with the dagger, or in fact any other situation that triggers an OA.