Form Validation
There are several ways how you can validate the user input before the form is processed by the Imixs Workflow Engine. The following section provides an overview of the various possibilities.
Required Inputs
With the tag required a mandatory input is defined:
<item name="order.name" type="text" label="Description:" required="true"/>
The input field is marked with a ‘*’ and an error message is shown if no field value was added on submit. 
Disabling Validation of Required Inputs
You can also disable the required validation for specific events like a ‘Cancel’ event by adding the following validation defintion into the correspondign event result:
<validation name="required">false</validation>

Confirm a Event Action
To force the user to confirm a event action you can optional add the Validation-Confirm Rule:
<validation name="confirm">Are you sure to cancel this request?</validation>
Validation Rules
The required tag is a simple way to define a validation. With the help of the Imixs Rule Plugin you can also define more complex business rules. For example you can verify if an input value has a minimum length:
var result={};
if (workitem.getItemValueString('order.number').length<5) {
result.isValid=false;
result.errorMessage='The order number must have at least 5 digits!';
}
You can place this rule in the Rule Property of the corresponding workflow Event:

The error text is shown if the validation failed:

Or testing a number size:
var result={};
if (workitem.getItemValueDouble('order.amount')<1.0) {
result.isValid=false;
result.errorMessage='The order amount must be more than 1 EUR!';
}
See the section Imixs Rule Plugin of the Imixs Workflow Engine for more details about using business rules.
Validation of Comments
In most cases you want to force the user to enter a comment if she reject an approval. This can be done with the following business rule:
var result={};
result.isValid=true;
if (workitem.getItemValueString('txtcomment') == '') {
result.isValid=false;
result.errorMessage='Please enter a comment.';
}
Validation of File Attachments
Using the Imixs Rule Plugin it is also possible to validate more complex data. For example you can ask if at least one document was attached to the form:
var result={};
if (workitem.getItemValueInteger('$file.count')==0) {
result.isValid=false;
result.errorMessage='Please attache the Purchase Order Document!';
}
Plugin Validation
The plugin class org.imixs.workflow.office.plugins.InputValidationPlugin can be added into a BPMN Model to support extended validation.
Validate duplicated data input
In the mode ‘DUPLICATE’ the InputValidationPlugin validates duplicated data inputs. The input item must be part of the lucene index and can be configured in the following way:
| Property | Type | Mandatory | Description |
|---|---|---|---|
input-item |
text | ✓ | Name of the item to be validated for duplicate values |
query-filter |
text | Optional query-filter (e.g. ($modelversion:approval*)) | |
error-message |
text | ✓ | Error message to be displayed in the UI (can include HTML) |
error-severity |
text | ✓ | Marks the severity of the validation (‘error’, ‘warning’, ‘info’ |
debug |
boolean | Debug mode |
Example:
<imixs-validation name="DUPLICATE"> <input-item>invoice.number</input-item> <query-filter>(type:workitem OR type:workitemarchive) AND ($modelversion:approval*)</query-filter> <error-message>The invoice number was already used!</error-message> <error-severity>warning</error-severity> <debug>false</debug> </imixs-validation>
error-severity
If the error-severity is set to ‘error’ the user input must be fixed. If the error mode is ‘warning’ or ‘info’ the error-message will be displayed but can be skipped by the user.