To compare the old value and new value in trigger we can use trigger new map and trigger old map.
Basically, to compare old field value of record with the new value in trigger we need to access trigger.oldmap and trigger.newmap. Salesforce provides trigger.oldmap where in all the old records are stored in map with keyset as their id’s. We can compare the old values with new values as in the below example. Lets understand how we can implement such a data validation by getting old value in triggers.