---
schema_version: "1"
id: e57257a4da345147171be354c89710131f4e715aa707f7e69a73fa4a556d9a48
title: Sample Number Validation Rules
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/fields_useful_validation_formulas_number.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.fields_useful_validation_formulas_number.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 5e4790c26304bde22aa1c89c31bf6f3c42c86799cd02c12262c173ea79479796
description: Examples for how to validate that users can't save a time card record with more than 40 hours in a work week, numbers can't be negative, and even or odd numbers.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Sample Number Validation Rules

Examples for how to validate that users can't save a time card record with more than 40 hours in a work week, numbers can't be negative, and even or odd numbers.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Contact Manager</strong>, <strong>Group</strong>, <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Database.com</strong> Editions</td></tr></tbody></table>

For more information on any of the formula functions used in these examples, see [Formula Operators and Functions](https://help.salesforce.com/s/articleView?id=platform.customize_functions.htm&release=264.0.0&type=5 "Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula, such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.").

## Time Cards Must Total 40 Hours

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e102">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e105">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e102 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e105 ">Ensures that users cannot save a time card record with more than 40
              hours in a work week. This example requires five custom fields on your
              custom object, one for each day of work.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e102 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e105 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>Monday_Hours__c + 
Tuesday_Hours__c + 
Wednesday_Hours__c + 
Thursday_Hours__c + 
Friday_Hours__c &gt; 40</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e102 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e105 ">Your total hours cannot exceed 40.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e102 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e105 ">
              <samp class="parmname">Top of Page</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Cannot Be Negative

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e187">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e190">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e187 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e190 ">Validates that a custom field called <samp class="parmname">Hours Worked</samp>
              is not a negative number.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e187 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e190 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>Hours_Worked__c &lt; 0</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e187 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e190 ">Hours Worked cannot be less than zero.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e187 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e190 ">
              <samp class="parmname">Hours Worked</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Must Be Even

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e275">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e278">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e275 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e278 ">Validates that a custom field called <samp class="parmname">Ark Passengers</samp>
              is a non-negative even number.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e275 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e278 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>OR(
   Ark_Passengers__c &lt; 0,
   MOD( Ark_Passengers__c, 2) &lt;&gt; 0
)
</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e275 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e278 ">Ark Passengers must be a positive even number.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e275 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e278 ">
              <samp class="parmname">Ark Passengers</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Must Be Odd

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e364">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e367">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e364 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e367 ">Validates that a custom field called <samp class="parmname">Socks Found</samp> is
              a non-negative odd number.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e364 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e367 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>OR(
   Socks_Found__c &lt; 0,
   MOD( Socks_Found__c, 2) = 0
)
</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e364 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e367 ">Socks Found must be an odd number.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e364 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e367 ">
              <samp class="parmname">Socks Found</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Must Be a Multiple of Five

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e452">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e455">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e452 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e455 ">Validates that a custom field called <samp class="parmname">Multiple of 5</samp>
              is a multiple of five.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e452 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e455 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>MOD( Multiple_of_5__c, 5) &lt;&gt; 0</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e452 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e455 ">Number must be a multiple of five.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e452 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e455 ">
              <samp class="parmname">Multiple of 5</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Must Be an Integer

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e540">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e543">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e540 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e543 ">Validates that a custom field called <samp class="parmname">My Integer</samp> is
              an integer.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e540 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e543 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>FLOOR( My_Integer__c) &lt;&gt; My_Integer__c</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e540 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e543 ">This field must be an integer.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e540 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e543 ">
              <samp class="parmname">My Integer</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Must Be Between -50 and 50

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e628">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e631">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e628 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e631 ">Validates that a custom field called <samp class="parmname">Volume</samp> is
              between -50 and 50.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e628 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e631 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>ABS( Volume__c) &gt; 50</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e628 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e631 ">Volume must be between -50 and 50.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e628 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e631 ">
              <samp class="parmname">Volume</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Number Range Validation

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e716">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e719">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e716 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e719 ">Validates that the range between two custom fields, <samp class="parmname">Salary
                Min</samp> and <samp class="parmname">Salary Max</samp>, is no greater than
              $20,000.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e716 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e719 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>(Salary_Max__c - Salary_Min__c) &gt; 20000</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e716 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e719 ">Salary range must be within $20,000. Adjust the Salary Max or Salary Min
              values.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e716 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e719 ">
              <samp class="parmname">Salary Max</samp>
            </td>

          </tr>
        </tbody>
      </table>

## Percentage Must Be Between Zero and 100

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:28.999999999999996%">
          <col style="width:71%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e807">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d219546e810">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e807 ">
              <strong>Description:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e810 ">Validates that a custom field called <samp class="parmname">Mix Pct</samp> is
              between 0 and 100%. Note that percent fields are expressed divided by 100 in
              formulas (100% is expressed as 1; 50% is expressed as 0.5).</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e807 ">
              <strong>Formula:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e810 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>OR(
   Mix_Pct__c &gt; 1.0,
   Mix_Pct__c &lt; 0.0
)
</code></pre>
            </td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e807 ">
              <strong>Error Message:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e810 ">Mix Pct must be between 0 and 100%.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e807 ">
              <strong>Error Location:</strong>
            </td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d219546e810 ">
              <samp class="parmname">Mix Pct</samp>
            </td>

          </tr>
        </tbody>
      </table>