What is Peach
Installing
Tutorials
Methodology
Introduction
Training
Enterprise
FAQ
Support Forums
Peach 3
Peach Pits
 General Conf
 Data Modeling
 State Modeling
 Agents
  Monitors
 Test
  Publishers
  Loggers
Running
Minset
Peach 2.3

License

Constraint Attribute

The constraint attribute specifies a scripting expression that helps Peach identify if the data element has been properly consumed for incoming data. The constraint expression must evaluate to true or false. True indicates that the incoming data was properly parsed into the data element. False indicates that an error has occurred. The constraint attribute does not affect how the value is mutated.

Note
Constraints are only executed when parsing data into a data element.
Tip
Constraints are typicaly slower than using Choice or the token attribute

The following special variables are available to the expression:

  • element — The data element instance

  • value — The value of the data cracked into the data element. This value will be cast to a string or byte array.

Example

<!-- Operate on number and check result -->
<Number name="constrainedNum" size="32" constraint="int(value) & 0xfefe == 5" />
<!-- Case insensitive equals -->
<String constraint="value.lower() == 'peach'" />

<!-- Value contains peach -->
<String constraint="value.find('peach') != -1" />
<!-- Length is less than 100 bytes -->
<Blob constraint="len(value) < 100" />