NI InsightCM™ SDK 3.3 Help
»View Product Info
Parent Topic: Device Type Definitions
Validation rules instruct the InsightCM web application to provide feedback to users when they configure a property field with invalid values. For example, you might want to alert users to required fields that they left empty or to conflicts they introduced between two related properties. If a property value violates the validation rule, the InsightCM web application applies visual styling to the property field and, optionally, prevents users from saving the device configuration.
||Note This definition is one part within the device type definition structure. In other words, when you export and import a device type definition, this definition is included.
You can classify a validation rule as a warning or an error depending on whether you want to allow users to save a device configuration that violates the validation rule.
- Warning—Display a red underline in the property field and display a tip strip that contains a custom message when users hover over the field.
- Error—Prevent users from saving the device configuration and display a line and tip strip on the field.
Components of a Validation Rule
You can define validation rules in the device definition or in asset definitions. Validation rules in JSON are objects that contain the following name-value pairs:
- Name—A unique name that describes the expression to evaluate.
- Type—(Optional for some property types) For property fields that you want to display on tabs of the Assets or Device Configuration page, the ID of the specific location where you want the property field to appear: DataGroup, Device, or OperatingState. For a description of each type, refer to Correlating Components with a Location in the InsightCM web application.
- Description—The message to display to users in a tip strip when you hover over the property field.
Action—One of the following strings, which specifies the action the InsightCM web application performs on the property field.
||Users cannot save the device configuration until the validation rule is no longer true. When users attempt to save, the InsightCM web application displays a dialog box that contains the Description.
||Users can save the device configuration.
- AffectedProperties—An array of strings that specify the keys of the property fields on which to display the line and tip strip.