You would use a ‘before insert’ and ‘before update’ trigger on the Opportunity object. The trigger would check the ‘CloseDate’ of each Opportunity record, and if the date is in the past, it would add an error message to the record.
trigger ValidateOpportunityCloseDate on Opportunity (before insert, before update) {
for(Opportunity opp : Trigger.new){
if(opp.CloseDate < Date.today()) {
opp.addError(‘Close Date cannot be in the past.’);
}
}
}