Is it posible to monitor and limit axis motion in runtime?

I want a behavior like the following in my program:
At any point in operation, if external axis 1 receives a command to rotate backward by greater than some amount (say 500 degrees), throw an error or perform an interrupt.

Is there a function that compares the previous robot target with the current target in the motion planner? Or a function that can monitor the joint deltas (p2-p1) calculated in runtime by the robot's inverse kinematic model?

I realize I could achieve this using some sort of work around like assigning robot targets to variables like pCurrentTarget and pToTarget and comparing those, but this is suboptimal.