Part Validation Examples
Part validation allows you to enforce rules on the values entered by the user. Validation is configured in the Advanced tab of the part using:
Set validation error via — selects the validation method
Validation error — contains the rule and the message shown when the rule fails
You can reference the value of any part using:
#REPLACE-PARTVALUE-<InternalName>||#Validation Methods Overview
Method
Capabilities
Typical Use Cases
Plain text
Valid when the field contains at least one character
Simple “field cannot be empty” checks
NCalc
Expression-based logic, string comparison, date comparison, math
Dates, numeric logic, conditional checks
JavaScript
Full scripting engine with conditional logic and custom error messages
Complex rules, multi-part validation, document template validation
Validation Examples
Below are common validation scenarios with examples for date logic, comparisons, and required fields.
1. Compare two fields (must be equal)
Scenario: Part FieldTwo must match the value of FieldOne.
Set validation error via: JavaScript
Validation error:
2. Compare dates (one date must be after another)
Scenario:
DateToCompareTo contains a reference date (possibly filled via a workflow).
DateAfterDateToCompareWith must be a later date.
Default value for today (reference date)
Default value type: NCalc Default value:
Validation rule
Set validation error via: JavaScript Validation error:
3. Date must be in the future
Scenario: The entered date must be today or later.
Set validation error via: NCalc Validation error:
4. Number must not be negative
Scenario: The part value must be zero or higher.
Set validation error via: JavaScript Validation error:
5. Display message when None is selected
Scenario:
When the field is a multi-select, and the option 'None of the above' is selected, we want to show a text that no other entries can be selected. THis message is only shown when another entry is selected.
Set validation error via: Javascript
Validation script:
var message_nl = "'Geen van bovenstaande' kan niet gecombineerd worden met andere antwoordopties.";
var message_en = "'None of the above' cannot be combined with other answer options.";
var value = cleanValue(#REPLACE-PARTVALUE-gdpr_nature_category_sensitive||value#);
var noneOfTheAbove = value.indexOf('None of the above') >= 0;
var selectedCount = value.split('||').length;
if (noneOfTheAbove && (selectedCount > 1)) {
// locale = CommonInterface.getCurrentLanguageCulture(); // doesn't exist
return message_nl + " / " + message_en;
if (locale == 'nl-BE') {
return message_nl;
}
return message_en;
}
function cleanValue(value) {
// little hack needed, because in the resulting value string, there were sometimes empty values for some reason
value = value.replace("||||", "||");
if (value.indexOf('||') == 0) {
value = value.substring(2, value.length);
}
if (value.indexOf('||') == value.length - 2) {
value = value.substring(0, value.length - 2);
}
return value;
}
Validation for Document Templates
Document Templates often require validation across multiple document parts. Using JavaScript validation allows you to check multiple fields and return detailed error messages.
Validation scripts for documents return an object:
5. Make two document fields required
Fields:
Doc_CategoryDoc_Versie
Set validation error via: JavaScript Validation error:
6. Make three document fields required
Fields:
Doc_CategoryDoc_VersionDoc_Version_date
Set validation error via: JavaScript Validation error:
Summary
This chapter provides clear examples for:
field-to-field comparisons
date validation
numeric validation
multi-field validation for document templates
differences between Plain text, NCalc, and JavaScript validation
By applying these patterns, you can enforce simple and advanced validation logic consistently across your templates.
Last updated
Was this helpful?