Block Negative Credit Limits
Your company tracks an internal credit ceiling on each customer, and data-entry typos keep producing negative amounts. You'll add the field — and make it defend itself.
Requirements
- Create a table extension that extends the
Customertable. - Add a field named
"Internal Credit Limit"of typeDecimal. - Give the field an
OnValidatetrigger that raises an error when the value is negative. The error message must contain the exact textmust not be negative. - Zero and positive values are accepted.
What the tests check
The grading tests validate a positive value and read it back, validate zero, and check with asserterror that validating a negative value fails with a message containing must not be negative — both for a large negative amount and for the boundary value -0.01.
Learn More
Hint 1
Validation logic for a single field lives in that field's
OnValidate trigger, inside the field declaration.Hint 2
Inside the trigger, compare the field to 0 and raise
Error(...) when it is negative.Hint 3
The tests check that the message contains exactly
must not be negative — for example Error('Internal Credit Limit must not be negative.'). Press Compile to check your code compiles — Submit runs the tests.
The code editor is desktop-only
Open this problem on a computer to write and run code. Reading the description, tests and discussion works fine here.