Can the damage command do less damage when using armor?

So i am making a magic pvp like datapack and i was wondering if i can make it so that wearing armor does less damage when being hit by magic. Is there a way to make wearing armor deal less?

Continue to help post