Again, a discussion on another forum prompts me to post a review of rules related to roughing the passer. In NCAA, the definition of a passer - a player who throws a forward pass - was changed in 2011 to consciously remove the requirement for the pass to be legal. This is because fouls against a passer are, generally, true safety fouls, and a passer needs to be protected, whether the pass is legal or illegal. The opponents of a player who throws a forward pass do not get a “free shot” on the passer, just because a pass may be illegal (thrown from beyond the NZ, second forward pass of the down, following a change of team possession, etc.).
Note that a player that throws a backward pass is not a “passer,” as defined, and does not have the enhanced protection afforded a passer.
This may be different from other rule sets. Be sure you know the rules for the game you are working.