Valstorm Administration & Development3 min read

Validation Rules Guide

Validation rules in ValStorm allow you to enforce data integrity by preventing users (or automations) from saving records that don't meet your business criteria.

📋 How It Works

A validation rule uses the Formula Engine to evaluate a specific expression every time a record is created or updated.

  1. Trigger: Validation occurs during the record save process, after formula fields are calculated but before the data is committed to the database.
  2. Evaluation: The rule's expression is calculated.
  3. Outcome:
    • If the expression returns TRUE: The validation passes, and the save continues.
    • If the expression returns FALSE (or an error): The validation fails. The save is blocked, and the custom error message is displayed to the user.

🏗️ Components of a Rule

ComponentDescription
NameA human-readable label for the rule (e.g., "Minimum Age Requirement").
API NameA unique identifier used by the system.
Rule ExpressionThe formula that must evaluate to TRUE for the data to be valid.
Error MessageThe message shown to the user if the rule fails. This can be a static string or a dynamic formula.

💡 Best Practices

1. The "Pass" Condition

Always write your expression as the condition that makes the data valid.

  • Correct: {{record.amount}} > 0 (The record is valid if amount is positive).
  • Incorrect: {{record.amount}} < 0 (This would block all positive amounts!).

2. Handle Blanks

Use ISBLANK() to ensure you aren't running calculations on missing data that might cause a rule to fail unexpectedly.

  • Example: IF(ISBLANK({{record.email}}), TRUE, CONTAINS({{record.email}}, "@"))

3. Descriptive Error Messages

Provide clear instructions on how to fix the error. Use dynamic formulas in error messages to show the user exactly what is wrong.

  • Static: "The discount is too high."
  • Dynamic: 'Discount of ' & {{record.discount_pct}} & '% exceeds the limit of 20%.'

🚀 Common Examples

Require a field based on another field

If the Lead Source is "Referral", the "Referred By" field must not be empty.

  • Expression: IF({{record.lead_source}} == 'Referral', NOT(ISBLANK({{record.referred_by}})), TRUE)
  • Error: "Referred By is required when Lead Source is Referral."

Prevent future dates

Ensure the "Birthdate" field is not set in the future.

  • Expression: {{record.birthdate}} <= TODAY()
  • Error: "Birthdate cannot be in the future."

Value ranges

Ensure a "Probability" field is between 0 and 100.

  • Expression: {{record.probability}} >= 0 && {{record.probability}} <= 100
  • Error: "Probability must be between 0 and 100."

Pattern enforcement

Ensure a code starts with "ACT-".

  • Expression: LEFT({{record.account_code}}, 4) == "ACT-"
  • Error: "Account codes must start with the prefix 'ACT-'."

🛠️ Implementation via UI

  1. Navigate to the Object Builder.
  2. Select your Object.
  3. Click the Validation Rules tab in the sidebar.
  4. Click New Validation Rule.
  5. Use the Formula Editor (with autocompletion) to build your expression and error message.
  6. Click Save Validation Rule.