← Back to Error Checking · Guides
Rule Validation
Checking whether a record conforms to a set of format, range, type, or business rules.
Learn
Checking whether a record conforms to a set of format, range, type, or business rules.
Rule validation is the process of confirming that a piece of data satisfies explicit constraints before it is accepted. Typical rule classes are: (a) format rules — the value matches a pattern like an email, phone number, or date; (b) range rules — the value falls within allowed minimum and maximum bounds; (c) type rules — the value is a number, string, or boolean as expected; (d) business rules — domain-specific invariants (e.g., the total of line items equals the invoice amount). A record is valid iff it passes every applicable rule; the error is the first rule it fails.
valid(record) ⇔ ∀ r ∈ rules : r(record) holds
- Email format: '[email protected]' ✓; 'user@@example' ✗
- Age range [0, 130]: 25 ✓; 200 ✗
- Business rule: invoice total must equal sum of line items
How to recognize it
- A record is presented with a set of stated rules or constraints
- The task asks whether the record is valid, or which rule it violates
- Rules may combine (all must pass) or be hierarchical (some required, some optional)
Common mistakes
- Stopping at the first rule that passes instead of checking every applicable one
- Confusing 'valid format' with 'correct value' (a well-formed email can still be wrong)
- Ignoring case sensitivity, leading/trailing spaces, or locale-specific separators