validValues

The validValues property (formerly the range property) indicates a set of values that are valid for user input. The property is used for numeric or character fields.

The property specifies an array literal of singular and two-value elements, as in the following examples:
  validValues = [ [1,3], 5, 12 ]
  validValues = [ "a", ["d", "i"]] 
Each singular element contains a valid value. Each two-value element contains a range. The following guidelines apply:
  • For numbers, the leftmost value is the lowest that is valid, the rightmost is the highest. In the first example, the values 1, 2, 3, 5, and 12 are valid for an INT field.
  • For character fields, user input is compared against the range of values, for the number of characters for which a comparison is possible. For example, the range ["a", "c"] includes (as valid) any input whose first character is "a", "b", or "c". Although the string "cat" is greater than "c" in collating sequence, "cat" is valid input.
    As a general rule, if the first value in the range is designated lowValue and the second is designated highValue, the user's input is valid if it passes any of the following tests:
    • User input is equal to lowValue or highValue
    • User input is greater than lowValue and less than highValue
    • The initial series of input characters matches the initial series of characters in lowValue, for as long as a comparison is possible
    • The initial series of input characters matches the initial series of characters in highValue, for as long as a comparison is possible

If the user's input is outside the specified range, EGL displays an error message; see validValuesMsgKey.

Examples

The following additional examples show possible ranges for the property:
  // valid values are 1, 2, 3, 5, 7, and 11
  validValues = [[1, 3], 5, 7, 11]

  // valid values are the letters "a" and "z"
  validValues = ["a", "z"]

  // valid values are any string beginning with "a"
  validValues = [["a", "a"]]

  // valid values are any string 
  // beginning with a lowercase letter
  validValues = [["a", "z"]]

  //.The string "baa" is NOT valid here
validValues = [ "a", ["bbb", "i"]]

  //.The string "baa" IS valid here
  validValues = [ "a", ["b", "i"]]

Compatibility

Table 1. Support for validValues property
Data item VGUI record Console UI Text Form Java Text Form COBOL Print Form Java Print Form COBOL
Yes Yes Yes Yes Yes* No No

* The following additional compatibility considerations apply:

Table 2. Compatibility considerations for validValues
Platform Issue
COBOL generation Text forms only support numeric fields and a single pair of valid values.