# Block Personal Email Addresses on Leads

**Type:** Apex trigger · **Difficulty:** Easy · **Object:** Lead · **Topics:** Lead, Email Validation, Before Trigger, addError

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/block-personal-email-leads

## Problem

Before a Lead is inserted or updated, block email addresses from common personal email providers: gmail.com, yahoo.com, and hotmail.com. Company email addresses should be allowed. Compare the domain without case sensitivity.

## Constraints

Keep the trigger bulk-safe and put no SOQL or DML statements inside loops.

---
Source: ForceChallenges · last updated 2026-10-13
