Field Formatting and Restrictions

Restricting field data to a specific format

Field data can be restricted to a particular format to ensure consistency in how a value is specified across your organization. For example, let's assume you have a field that stores phone numbers. Different users in your organization might use different notations to specify a phone number, such as  (310) 555-1212, (310) 555 - 1212, 310-555-1212, etc. Restricting the format in which a value can be typed in ensures that your field data will be formatted consistently. Similarly, you might have a number field to store four-digit invoice numbers, and want to ensure that all values in that field fall between 1000 and 9999; you can do this with a numeric field constraint. Field data that has been input and formatted in a consistent manner makes searching for that data much easier.

Field data can only be restricted for certain field types: text fields and numeric fields (number, integer and long integer). The restrictions that a particular character field will have are determined by regular expressions, a notation used to define a pattern of text. For more information, see Regular Expression Reference. The restrictions that a particular numeric field will have are determined by numeric relational operators. For more information, see Relational Operator Reference. You can also view sample field constraints in Common Patterns. These constraints demonstrate the sample notation that can be used to constrain field data.

To place constraints on a field

  1. From the Field Properties dialog box, click Constraints.

  2. This will open the Field Constraints dialog box. ClosedClick to view screenshot.
  3. Under Regular Expression Constraint, specify the regular expressions for the data to be allowed in the field. If you are unsure of the pattern that you would like to use, click Choose to open the Template Constraints dialog box. Select the desired constraint and click OK.
  4. Under Constraint Violation Message, specify the message that will appear when a user attempts to assign a field value that does not comply with the pattern specified in the previous step.
  5. Click OK to close the Template Field Constraints dialog box.
  6. Click OK to save your changes to the field.

Note:  You can also open the Field Constraints dialog from the Template Properties dialog. Open the Template Properties dialog, select the field in question, and click Constraints. Proceed from step 2 above.

To place constraints on a field 

  1. Click on a field to open the Field properties page.

  2. Under Regular Expression Constraint, specify the regular expressions for the data to be allowed in the field. Above this field, there will be two examples for the field type you have selected. ClosedClick to view screenshot.
  3. Under Constraint Violation Message, specify the message that will appear when a user attempts to assign a field value that does not comply with the pattern specified in the previous step.
  4. Click Save to save your changes to the field.

Note:  You can also open the Field Constraints dialog from the Templates option. Select Templates and select the template. Click under Constraint for the desired field. Proceed from step 2 above.

Using regular expressions

The following reference describes the parts of a regular expression that can be combined to form a character field constraint.

When specifying constraints, you may want certain characters to be automatically assigned to a field, which can be done by typing the characters where you want them to appear in the field. The exceptions are characters that have been reserved for use by regular expressions. A list of these characters can be viewed from the Symbol column of the table below. Reserved characters can be automatically assigned to a field by placing a backslash prior to the reserved character. For example, if your organization decides that phone numbers should be specified as (310) 555-1212, you would specify the following expression:  \(\d\d\d\) \d\d\d-\d\d\d\d. Notice that the parentheses have been escaped with a backslash, while the dash has not been. Both parentheses and dashes are reserved characters. However, dashes can never be used without brackets, therefore they are treated as a regular character and do not require a backslash. Assigning this constraint to a field will create visual indicators as to how field data should be formatted. In the example stated above, blank fields will look like "(   )    -    ." As you can tell, users will not need to type the parentheses or the dash when specifying a phone number. These symbols are automatically shown to indicate what the format of a phone number should look like.  

The following table describes each regular expression that can be used to establish a pattern that field data must match.

Name Symbol Description
Any Character . Any single character.
Character in Range [] Any character inside the brackets. For example, the expression [abc123] allows only any of the following characters:  "a," "b," "c," "1," "2," or "3."
Character Not in Range [^] Any single character except for those inside the brackets. For example, the expression [^abc123] allows only any character except for:   "a," "b," "c," "1," "2," or "3."
Range Character [-] Any single character contained within the specified range. For example, the expression [0-9] allows only any number that falls between 0 and 9.
Beginning of Input ^ Requires the expression that follows it at the beginning of the user-defined value. For example, the expression ^[abc123] allows only field data that starts with either "a," "b," "c," "1," "2," or "3."
End of Input $ Requires the expression that precedes it at the end of the user-defined value. For example, the expression [abc123]$ allows only field data that ends with either "a," "b," "c," "1," "2," or "3."
Not ! Requires that the expression following the symbol (!) not be found in the field data. For example, the expression a!b allows only field data containing an "a" when it is not immediately followed by "b."
Or | Requires one of two expressions. For example, the expression he|she allows only field data that is set to either "he" or "she."
0 or More * The preceding expression can occur zero or more times. For example, the expression [0-9]* allows any set of consecutive digits or no digits at all.
1 or More + The preceding expression can occur one or more times. For example, the expression [0-9]+ allows any set of consecutive digits.
Previous Statement is Optional ? The preceding expression is optional. Data satisfying the expression may be specified as field data or a user can choose to not enter it. For example, the expression [0-9][0-9]? allows only a single or double digit.
Group () Groups an expression together. For example, the expression (t|T)he allows only field data that is set to either "the" or "The".
Escape Character \ Either an abbreviation (see table below) or that the next character be translated literally. This character should only be used for reserved characters, such as those listed under the Symbol column of this table. For example, \d+ allows only one or more digits, while \d\+ allows a digit followed by a plus sign.

Character Classes

A character class can be used to restrict the character for a particular field.

Name Symbol Description
Alphanumeric [[:alnum:]] Any alphanumeric character.
Alphabetic [[:alpha:]] Any alphabetical character in the following ranges:  a-z and A-Z.
Space/Tab [[:blank:]] A space or a tab.
Digit [[:digit:]] Any digit. A valid character is a whole number from 0 to 9.
Lower-case [[:lower:]] Any lower-case character (i.e., a-z).
Printable [[:print:]] Any printable character.
Punctuation [[:punct:]] Any punctuation character.
Space [[:space:]] Any whitespace character.
Upper-case [[:upper:]] Any upper-case character (i.e., A-Z).
Hexadecimal [[:xdigit:]] Any hexadecimal digit (i.e., 0-9, a-f and A-F).
Word [[:word:]] Any word character. Valid characters are all alphanumeric characters and underscore.

Abbreviations

The following table describes the various abbreviations for specifying a regular expression.

Name Symbol Description
Character . Any single character.
Decimal Digit \d Any single decimal digit. Corresponding syntax: [[:digit:]]
Non-Decimal Digit \D Any character except for a single decimal digit. Corresponding syntax: [^[:digit:]]
Space \s A single space character. Corresponding syntax: [[:space:]]
Non-Space \S Any character except for a single space character. Corresponding syntax: [^[:space:]]

Using relational operators to constrain numeric fields

The following reference describes the relational operators that can be combined to form a numeric field constraint.

The following table describes each operator that will be used to compare a value in a field with the range of valid values for that field. These must be used in conjunction with number values: for instance, to specify that the value must be greater than 1000, the constraint would be written as ">1000".

Name Symbol Description
Less Than < A valid value is less than the specified number.
Greater Than > A valid value is greater than the specified number.
Less Than or Equal To <= A valid value is less than or equal to the specified number.
Greater Than or Equal To >= A valid value is greater than or equal to the specified number.
Equal To = A valid value is equal to the specified number.
Not Equal To <> A valid value does not equal the specified number.

Boolean Logic Operators

The following table describes the Boolean operators that can be used to combine relational operators. Either the name or the symbol can be used; names are not case sensitive.  For example, to specify that a value must be between 1000 and 9999, the constraint could be written either as ">=1000 AND <=9999" or as ">=1000 & <=9999".

Name Symbol Description
AND & Both constraints must be met for the value to be valid.
OR | At least one constraint must be met for the value to be valid.
NOT ! The constraint must not be met for the value to be valid.

Order of Precedence

A numeric constraint can be created with more than one Boolean operator. In that case, the string will be analyzed in the following order: AND will be applied first, followed by OR, followed by NOT. Parentheses will be used for grouping.

Examples

The following examples demonstrate the use of the various relational and Boolean operators.

Desired Constraint Numeric Constraint String
A valid value must be greater than four. >4
A valid value must not be greater than 999. !>999
A valid value must be between 1 and 10, not including 1 and 10. 1 < & < 10
A valid value must be either between 100 and 200 or between 500 and 900, including 100, 200, 500 and 900. (>=100 & <=200) | (>=500 & <=900)

Common constraint patterns

This is a short list of common patterns that can be used to restrict field data, provided only as an introduction to the many uses of regular expressions to ensure proper data formatting. These, like any other patterns, can be modified to best suit the needs of your organization.

Note:  These common patterns primarily use abbreviations for simplicity. However, you may also use any supported symbols when setting up a constraint.

Common Character Constraint Patterns

Type Pattern Example
Phone Number

((xxx) xxx-xxxx format)

\(\d\d\d\) \d\d\d-\d\d\d\d (562) 988-1688
Phone Number

(xxx-xxx-xxxx format)

\d\d\d-\d\d\d-\d\d\d\d 562-988-1688
Social Security Number

(xxx-xx-xxxx format)

\d\d\d-\d\d-\d\d\d\d 123-45-6789
Zip Code

(xxxxx or xxxxx-xxxx format)

\d\d\d\d\d(-\d\d\d\d)? 90807

Or:

90807-1234

Note: The Laserfiche Windows client will not provide a visual indication of the format for patterns that use optional characters, such as the Zip Code field in the example above.

Common Numeric Constraint Patterns

Type Pattern
Four-digit number >=1000 &  <=9999
Positive numbers only >=0

Note: The Laserfiche Windows client does not provide visual indication of numeric constraints.

Informing users when invalid data is entered

A message will appear when a user attempts to assign a field value that does not satisfy the constraint configured for a field. This message can be customized, so that your organization may provide specific instructions on how a field value should be formatted.

In addition to informing users of the proper format, you may want to consider providing examples of how field data should be formatted. For example, if your regular expression looked like:  \(\d\d\d\) \d\d\d-\d\d\d\d, you may want to use the following message:

The value assigned to the field "FieldName" has not been properly formatted.

The proper format for this field is the following: (xxx) xxx-xxxx.

An example of a properly formatted phone number is: (562)988-1688.

Tip:  When configuring a message, you can place sentences on different lines by pressing ENTER to start the next line.

To place constraints on a field

  1. From the Field Properties dialog box,click Constraints. This will open the Field Constraints dialog box.



  2. Under Constraint Violation Message, specify the message that will appear whenever a user attempts to assign a field value that does not comply with the pattern specified in the previous step.
  3. Click OK to close the Template Field Constraints dialog box.
  4. Click OK to save your changes to the field.

Note:  You can also open the Field Constraints dialog from the Template Properties dialog. Open the Template Properties dialog, select the field in question, and click Constraints. Proceed from step 2, above.

To place constraints on a field 

  1. Click on a field to open the Field properties page.
  2. Under Constraint Violation Message, specify the message that will appear whenever a user attempts to assign a field value that does not comply with the pattern specified in the previous step. ClosedClick to view screenshot.

  3. Click Save to save your changes to the field.

Note:  You can also open the Field Constraints dialog from the Templates option. Select Templates and select the template. Click under Constraint for the desired field. Proceed from step 2 above.

Field display formats

You can customize the way that Laserfiche displays date, time and number field values. This customizing can be done on a field-by-field basis. For example, you might choose to always display one number field as a percentage (so that the value "90" will be displayed as "90%"), and a different number field as currency (so that the value "345.98" will be displayed as "$345.98").

You can choose from several pre-defined formatting options for Date, Time, Date/Time and Number fields, or you can create a custom field display.  For more information on customizing the field display, see Custom Field Display.

To determine how your fields will be displayed

  1. From the Field Properties dialog box,click Edit Format....
  2. This will open the Edit Format dialog box.
  3. Select the format you would like to use. The available formats vary depending on the field type.
    • Date Fields
      • Long date. This format matches the "long date" format specified by the Windows regional settings on the Windows client computer.
      • Short date. This format matches the "short date" format specified by the Windows regional settings on the Windows client computer.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Time Fields
      • Long time. This format matches the "long time" format specified by the Windows regional settings on the Windows client computer.
      • Short time. This format matches the "short time" format specified by the Windows regional settings on the Windows client computer.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Date/Time Fields
      • Long date/time. This format matches the "long date and time" format specified by the Windows regional settings on the Windows client computer
      • Short date/time. This format matches the "short date and time" format specified by the Windows regional settings on the Windows client computer
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Number Fields
      • General. This format displays numeric values without commas, and with any number of digits on either side of the decimal point.
      • Percent. This format displays numeric values as a percentage.
      • Scientific. This format displays numeric values in scientific notation, with the character "E" separating the significant digits from the exponent.
      • Currency. This format display numeric values as currency. You can specify the currency type to use by selecting it from the list.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Number Field Display for more information.
  4. Click OK to save your changes to field display.

To determine how your fields will be displayed

  1. Click on a field to open the Field properties page. ClosedClick to view screenshot.

  2. Select the desired Type of field. The format options will appear. The available formats vary depending on the field type.
    • Date Fields
      • Long date. This format matches the "long date" format specified by the Windows regional settings on the Windows client computer.
      • Short date. This format matches the "short date" format specified by the Windows regional settings on the Windows client computer.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Time Fields
      • Long time. This format matches the "long time" format specified by the Windows regional settings on the Windows client computer.
      • Short time. This format matches the "short time" format specified by the Windows regional settings on the Windows client computer.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Date/Time Fields
      • Long date/time. This format matches the "long date and time" format specified by the Windows regional settings on the Windows client computer
      • Short date/time. This format matches the "short date and time" format specified by the Windows regional settings on the Windows client computer
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Date and Time Field Display for more information.
    • Number Fields
      • General. This format displays numeric values without commas, and with any number of digits on either side of the decimal point.
      • Percent. This format displays numeric values as a percentage.
      • Scientific. This format displays numeric values in scientific notation, with the character "E" separating the significant digits from the exponent.
      • Currency. This format display numeric values as currency. You can specify the currency type to use by selecting it from the list.
      • Custom. Define your custom format by typing a formatting pattern in the box. See Custom Number Field Display for more information.
  3. Click Save to save your changes to field display.

Custom date and time field display

A date or time pattern is a string of characters that will be replaced by the actual date and time value input in a field. The pattern determines what date or time information will be displayed, and how it will be displayed. Since the default date and time display options use the client computer settings, you can use a custom date, time or date/time field if you want to display dates and times consistently between client computers. You can also use them to display information not contained within the default date and time fields, such as the quarter or era.

The table below lists all of the possible elements of a date or time pattern, the symbol used to represent them, and an example of how the final value would be displayed. In some cases, the same element may have several different display options.  For example, the symbol y is used for the year, but you can control whether to display all four digits, such as "2024" (in which case you would use the pattern "y" or "yyyy"), or to display just the last two digits, such as 24" (in which case you would use the pattern "yy").

"Stand Alone" values refer to those designed to stand on their own, as opposed to being with other formatted values. if you want to store the current quarter alone, as “2nd quarter”, you would use the stand alone format (QQQQ), whereas “2nd quarter 2021” would use the regular format (qqqq yyyy). In some locales the “Stand Alone” outputs might differ from those of their regular symbol counterparts.

Description Symbol Example
Era Designator G AD
Year (full) y or yyyy 2024
Year (abbreviated) yy 24
Year for "Week of Year" Y 2024
Quarter (numeric) Q or QQ 02
Quarter (abbreviated) QQQ Q2
Quarter (full) QQQQ 2nd Quarter
Stand Alone Quarter (numeric) q or qq 02
Stand Alone Quarter (abbreviated) qqq Q2
Stand Alone Quarter (full) qqqq 2nd Quarter
Month (numeric) M or MM 09
Month (abbreviated) MMM Sept
Month (full) MMMM September
Month (initial) MMMMM S
Stand Alone Month (numeric) L or LL 09
Stand Alone Month (abbreviated) LLL Sept
Stand Alone Month (full) LLLL September
Stand Alone Month (initial) LLLLL S
Week of Year w 182
Week of Month W 2
Day of Month d 5
Day of Month (two-digit) dd 05
Day of Year D 205
Day of Week in Month (e.g., 2nd Wed. in July) f 2
Modified Julian Day Number g 2451334
Day of Week (abbreviated) E, EE or EEE Tues
Day of Week (full) EEEE Tuesday
Day of Week (initial) EEEEE T
Local Day of Week (if Mon. is 1, Tue. is 2, etc) e 3
Stand Alone Local Day of Week c 3
AM/PM marker a AM
Hours in AM or PM (1-12) h 7
Hours in AM or PM (1-12) (two-digit) hh 07
Hours in AM or PM (0-11) K 5
Hours in AM or PM (0-11) (two-digit) KK 05
Hours in Day (0-23) H 8
Hours in Day (0-23) (two-digit) HH 08
Hours in Day (1-24) k 20
Hours in Day (1-24) (two-digit) kk 20
Minute in Hour m 3
Minute in Hour (two-digit) mm 03
Second in Hour s 9
Second in Hour (two-digit) ss 09
Single Quote '' '

Letters may be included in the pattern, but they must be enclosed in single quotes. For example, the pattern "qqqq 'of' yyyy" would be returned as "2nd Quarter of 2019". Other characters besides single quotes and letters may be included as-is, without needing to be enclosed. For example, the pattern "hh:mm:ss" would return "09:15:45".

Examples

Pattern Result
yyyy-MM-dd hh:mm:ss a 2019-02-19 04:31:16 PM
EEE, MMM d, ''yy Wed, Feb 19, '19
qqqq 'of' yyyy 1st Quarter of 2019
h:mm a 4:31 PM

Custom number field display

A number pattern is a string of characters that consists of some combination of literal characters and symbols. A literal character is a character that will be displayed as you type it in the field format; a symbol will be replaced by the value or values it represents. The pattern determined by the combination of these will control how numbers are displayed in that field. In some cases, a symbol might indicate that a particular operation will be performed on the value for display purposes.

The table below lists the possible elements of a number pattern and the symbol used to represent them in the pattern. Examples are provided below the table.

Description Symbol
Digit 0
Rounding increment 1-9
Significant digit @
Digit, zero shown as absent #
Decimal separator or monetary decimal separator .
Minus sign -
Grouping separator ,
Separator between mantissa and exponent in scientific notation E
Prefix positive exponents with a localized plus sign +
Separator between positive and negative sub-patterns ;
Multiply by 100 and show as percentage %
Multiply by 1000 and show as per mille
Currency sign, replaced by currency symbol ¤
Currency sign, replaced by international currency symbol ¤¤
Currency sign, replaced by currency plural names (e.g., "US dollars") ¤¤¤
Quote special characters in prefix or suffic '
Pad character indicator *

Examples

Pattern User Input Display Value Notes
#,###,##0.0# 1234567.8 1,234,567.8 The character used to separate groups of digits depends on your local settings.  In some regions, a comma is used, as in the display value in this example, but in other regions another character (such as a period) might be used.
#,###,##0.0# -1234567.8 -1234,567.8 This pattern is identical to the above. If no special formatting is indicated for negative numbers, the same formatting as for positive numbers will be used, prepended with a minus sign.
###,##0.0;'('-###,##0.0')' 1234.5 1,234.5 If you want to display positive and negative numbers differently beyond simply adding a minus sign, you can separate a positive and negative pattern with a semicolon. This pattern contains both a positive and negative subpattern, and this example of user input demonstrates the handling for positive numbers, specified by the pattern before the ";" symbol.
###,##0.0;'('-###,##0.0')' -1234.5 (-1,234.5) As with the above example, this pattern specifies both a positive and negative display pattern. This example of user input demonstrates the handling for negative numbers, specified by the pattern after the ";" symbol. In this case, negative numbers are indicated by a minus sign before the value, and are contained within parentheses.
#1,000 1234567.8 1,234,570 The "100" preceding the final 0 in the string indicates that the value should be rounded to the nearest hundreds place. Note that the actual value set has not been lost; the server is still storing the entire value down to the tenth place. The rounded value is for display purposes only.
###,##0' kph' 55.5 55.5 kph The value in single quotes is a suffix. It is printed as-is and is not parsed, but provides additional information about the value (in this case, indicates that it is a speed in kilometers per hour).
#,###,###,###0.00 ¤¤¤ 1159.9 1,159.90 US Dollars The ¤ symbol written three times in a row indicates that the currency type should be written out in full.
*0#####0.0 1234.5 0012345.6 The "*0" string at the beginning of the pattern indicates that the character 0 should be used as a padding character if the input value is shorter than the number of digits specified. Since the pattern specifies six digits before the decimal point, two 0 characters are prepended to the string for display. This allows you to maintain consistent display lengths even for input numbers of varying lengths.
@@@ 1234.5 1230 The @ character indicates the number of significant digits to display. In this example, exactly three significant digits should be displayed. The entire number is saved on the server, but only the specified significant digits will be visible to users browsing the repository.
@@## 1234.5 1234 Combining the @ and # characters allows you to set a maximum and minimum number of significant digits to display. In this example and the next, a value will be displayed with no fewer than two or more than four significant digits. The input string for this example contains five digits, so the fifth is not displayed.
@@## 1 1.0 As in the above example, this pattern indicates that no fewer than two or more than four significant digits should be displayed. Thus, the value "1" will be displayed with two significant digits, as "1.0".
0.###E0 1234.5 1.234E3 Scientific notation is a way of expressing numbers as a combination of a mantissa (the significant digits of the number) and an exponent. This example displays a number in scientific notation with four significant digits.