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:


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_Category

  • Doc_Versie

Set validation error via: JavaScript Validation error:


6. Make three document fields required

Fields:

  • Doc_Category

  • Doc_Version

  • Doc_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?