Draft Tips and tricks: Enforce business rules using data validation on String properties

AODocs can help you enforce business rules for users filling in the property values. This articles provides examples of how to leverage data validation rules for String or Text properties.

Learn more: Configure data validation for custom properties

Enforce a minimum and or maximum number of words
 Enforce a phone number format
Enforce a reference format


Enforce a minimum and or maximum number of words

Example:
On my document class “Project”, I need to write a quick description of the content of my document in a few words. The contributors should be allowed to enter a limited number of words to describe the document.

Solution:
As a library administrator, I can configure a property “Quick description” as a String field. A String field can contain 400 characters maximum. Reviewers of my documents need to quickly understand the document’s description at first glance and the limit of 400 characters is too high. With the data validation rule, I can force my users to enter a description that contains from 1 to 10 words maximum or limit the number of characters to 100.

Data validation rule to enter from 1 to 10 words: ^(?:\w+\W*){1,10}
Data validation rule to enter from 1 to 100 characters: ^.{1,100}

image_01.png
Configuration of the data validation - 10 words maximum

image_02.pngInvalid entry on the field controlled by data validation


Enforce a phone number format

Example:
On my document class “Supplier”, I need to record my supplier’s project manager phone number. I want phone numbers to be displayed with a specific format so that they’re easily readable.

Solution:
As a library administrator, I can configure a property “Phone” as a String field and implement a validation rule on a String field to allow users to enter numbers, spaces, dashes and the plus sign. This will allow several phone number formats be entered, for example:
628 226-5980
+42 66787890978
0033 7 87 78 98 09

Data validation rule: ^[- +()]*[0-9][- +()0-9]*$

image_03.png
Configuration of the data validation - only phone numbers accepted

image_04.png
Invalid entry on the field controlled by data validation


Enforce a reference format

Example:
On my document class “Invoice”, I need to reference the invoice number (Invoice #) and the Change Order number (CO#”).
In my company, all invoice numbers are composed of three letters (first three letters of the customer name) and 7 numbers corresponding a the issued date of the invoice ("12042018").
For change order numbers (CO#), my company rule is to have three figures for each CO#. Some CO# contain leading zeros ("001", "012", etc.).

Solution:
As a library administrator, I can configure two properties “Invoice #” and “CO#” as String fields with a validation rule. The validation rule of the “Invoice #” will force contributors to enter an invoice composed of three capital letters and 8 numbers separated by a hyphen. The validation rule of the “CO #” will force contributors to enter a 3 figure number with the possibility of leading zeros.

Data validation rule for Invoice #: [A-Z]{3}-[0-9]{8}
Data validation rule for CO #: ^[0-9]{3}

image_05.png
Configuration of the data validation - Contract # and Invoice #

image_06.png
Invalid entry on the field controlled by data validation

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.