# Prevent Negative Opportunity Amounts

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

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/prevent-negative-opportunity-amounts

## Problem

Before an Opportunity is inserted or updated, stop it if Amount is less than zero. Zero and positive amounts are allowed. Give the user a simple error message.

## Constraints

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

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