🔧 Build it · 60 XP
Validation rules
Validation rules
A validation rule blocks a save when its formula evaluates to true. It's the declarative way to say "this data is wrong".
// Formula returns TRUE → save is blocked and the error is shown
AND(
ISPICKVAL(Status__c, "Done"),
ISBLANK(Due_Date__c)
)
Validation rules run on every save, whether it comes from the UI, the API, Data Loader or Apex. That's why they're more reliable than checks in a single screen.
Your mission
Add a validation rule on Quest__c so that XP must be between 0 and 1000.
| Setting | Value |
|---|---|
| Rule Name | XP_Range |
| Formula | XP is less than 0 or greater than 1000 |
| Error Message | Something that mentions XP, e.g. "XP must be between 0 and 1000." |
| Error Location | The XP field |
Hints
OR(condition1, condition2)returns true if either is true- Blank XP is fine. Comparisons with a blank number return false
When you Submit, Quill tries saving quests with 5000, -1 and 50 XP, and expects the first two to be blocked.
🦝 Validation rules also fire when Apex does DML. That's why Quill's checks wrap the insert in try/catch, and so should you when it matters.