External Form Validation - tsgrp/HPI GitHub Wiki
Overview
External Form validation is a way of taking a form property and running OpenContent Conditions on the individual property.
See the Conditions wiki page for more information on how conditions are configured. For HPI, these conditions must be exposed not only as OpenContent conditions, but also as form-related conditions. When these are hooked up, the property will automatically reach out to OpenContent to validate the property and render the form invalid if necessary.
Validation
The Validation works by extending the form support validator when it is configured; this is what handles actually making the call to OpenContent to approve/reject the valid property value. This call is asynchronous, so feedback is not always instantaneous, but it does ensure things like enforcing a unique object name are enforced.
Configuration
There are two key steps to the configuration of these external form property rules:
Exposing Condition in Config-Project
First, conditions available as optional property conditions must be exposed in the config-project of the HPI project. An example configuration is available below. "modules/hpiadmin/formconfig/formattribute": { availableConditions: [{ ruleLabel: "Attribute is Unique", ruleValue: "condition-isattributeunique-conditionevaluator" }] },
Note that a label is provided for administrators maintaining the system.
The ruleValue must exactly match the name of the OpenContent condition bean, otherwise HPI will be unable to resolve the condition.
Configuring the Condition for a Given Property
Next, the HPI Admin allows you to actually specify - for a required field**** - what the condition which validates the property is.
This configuration can be performed in the Form Config screen; simply scroll to your chosen property and select the "Rules" dropdown, and from there, select the Condition which applies. There will also be a checkbox "Clear Invalid Selected Values" that when checked will clear out the control if the value comes back as invalid. Note that if you do not see an option to configure conditions, then the conditions are not yet configured in the HPI config-project configuration.