Defining Schema Rules using UI
Last updated
Last updated
Schema rules have been created to enable authorised policy users to offer assistance to other users (and/or themselves) with data input and/or data evaluation. Schema rules define acceptable values and their ranges for schema fields (and correspondingly input fields in Guardian forms). They are activated in the UI whenever the form is viewed by users, and re-evaluated every time any of the values on the form is changed. Rules can contain mathematical formulas and logical if-then-else flow, and source data from any field in the current schema as well as any other schemas/documents that are present in the corresponding policy. When rules are evaluated they produce a binary โpass/failโ output, which is displayed in the UI as green and amber field highlights correspondingly.
Each Policy can have associated by Schema rules. The list of schema rules is displayed in the corresponding section of the UI, which provides the facility to enable/disable each of them individually.
To initiate the creation of a new schema rules users need to click on the โCreate Newโ button in the corresponding UI section.
After a rule has been created it should be configured to be meaningful, the process can be started by clicking the edit icon in the rules grid.
1.3.1 General configuration
Specifying the rules name and its โtargetโ policy is mandatory.
1.3.2 Configuring fields and schema
To source data from documents rule creators need to specify which fields from which schemas should be retrieved. Schema tree view shows policy schemas in a hierarchical structure, and allows to select the target fields.
1.3.2.1 Search
In complex policies the complexity of schema structures can be difficult to navigate, rules creators could use search tool to optimize their work.
1.3.2.2 Selection
Clicking on a schema box opens the side menu which lists all the fields available in the selected schema.
Note: sub-schemas do not produce corresponding document, when such sub-schema is selected in the schema view the right hand panel shows the fields from the parent schema of which this sub-schema is a part.
1.3.2.3 Properties
By default searching for fields is performed on the basis of the values in their description field, however it is possible to search for matches in their โpropertyโ values by navigating into the corresponding tab.
Note: some schema fields might not have or have empty property fields, such cases are displayed as greyed-out items in the list and their โdescriptionโ field is shown instead
1.3.3 Configuring formulas
The selected schemas and their fields constitute โinputโ data for the rules. The second stage of rule configuration is specifying the rules themselves and their formulas.
The system automatically creates short variable names for the target fields, each of which then can be used as a rule target (for which to specify the acceptable values/ranged) or used in a formula to specify those for another field variable.
1.3.3.1 Editing rules
There are a number of templates that can be used when configuring or editing rules. When a template is not selected for an existing rule it indicates that the rule is effectively non-existent for this field.
1.3.3.1 Templates
Formula
Formula is the most flexible and most powerful rule template.
Formulas must be configured such that their evaluation results in a true or false values (or numerical 0/1). Formulas support mathematical operations from https://mathjs.org/ and Microsoft Excel function as supported by https://formulajs.info/functions/. Formulas can feature any or all fields which have been selected in the previous steps.
Range
Ranges are simplified rules which verify that the value of the target field falls between the two borderline values specified.
Condition
This template allows for configuration of logical flows which can evaluate conditions and employ different formulas depending on the results of those evaluations.
IF โ a condition to evaluate , must evaluate to โtrueโ or โfalseโ THEN โ the rule if the condition is โtrueโ ELSE โ the rule which would would be employed if none of the โifโ conditions above resolved to โtrueโ
Note: in cases where more than one โifโ condition would resolve to true only the first โthenโ gets applied
The conditions are specified as formulas, which are subject for the principles and conventions specified above.
Formulas support notations for the following typical operations:
Text โ compare the values of a textual field to a text
Range โ simplified notation to check if the value is in the specified range
Enum โ if the field of a type โenumโ this option allows the selection of a single or multiple values from the enum for matching. If any of these values match the formula is considered to have been resolved to โtrueโ.
1.3.3.3 Preview
Preview option helps users to test the behaviour of the formulas during their configuration.
Users are required to manually populate the values for the โinputโ fields so to trigger the evaluation of the formulas.
If the formula contains an error, or the system is unable to calculate the resulting value the result field would be highlighted in red.
If the evaluation was successful the result field would be highlighted in amber (if the value โfailedโ the evaluation) or in green (if it was a โsuccessโ).
Once all editing is done the template must be saved.
Rules can not be published externally. The equivalent action which makes the system to apply rules as describe above is their โactivationโ.
Note: Rules can be activated/deactivated at any time.
Rules would be downloaded and evaluated every time a document with the associated active rules is being edited via the corresponding Guardian form.
Rules are also valued when such document is being viewed.
New rules would be applied to the documents which have been created before the rules have been specified or activated.
There are specific permissions for working with rules
Read, Create โ allows to view, create new, and activate existing schema rules
Execute โ allows to evaluate the existing rules when editing or viewing their corresponding documents
By default Standard Registries are assigned all 3 permissions. Default role has only Evaluate permission.
Schema rules can be exported to and imported from files.
When importing the rules they effectively become the rules of the importing Guardian instance with no dependency or relations to the instances that originally produced and exported the rules.
API
Post /api/v1/schema-rules/
Permissions: SCHEMAS_RULE_CREATE
Creation of the new schema rule
Get /api/v1/schema-rules/
Permissions: SCHEMAS_RULE_READ
Retrieve the schema rules.
Get /api/v1/schema-rules/:ruleId
Permissions: SCHEMAS_RULE_READ
Retrieve the configuration of the rule by its ID
Put /api/v1/schema-rules/:ruleId
Permissions: SCHEMAS_RULE_CREATE
Update the configuration of the rule with the corresponding ID
Delete /api/v1/schema-rules/:ruleId
Permissions: SCHEMAS_RULE_CREATE
Delete the rule by its ID
Put /api/v1/schema-rules/:ruleId/activate
Permissions: SCHEMAS_RULE_CREATE
Activate the rule with the specified ID
Put /api/v1/schema-rules/:ruleId/inactivate
Permissions: SCHEMAS_RULE_CREATE
Deactivate the rule with the specified ID
Get /api/v1/schema-rules/:ruleId/relationships
Permissions: SCHEMAS_RULE_READ
List all the schemas and policy relevant to the rule with the specified ID
Post /api/v1/schema-rules/data
Permissions: SCHEMAS_RULE_EXECUTE
Retrieve all the data needed for evaluating the rules
Post /api/v1/schema-rules/:policyId/import/file
Permissions: SCHEMAS_RULE_CREATE
Create a new rule from the file
Post /api/v1/schema-rules/import/file/preview
Permissions: SCHEMAS_RULE_CREATE
Load the file and return its preview
Get /api/v1/policy-statistics/:ruleId/export/file
Permissions: SCHEMAS_RULE_READ
Export the selected rule (by ID) into the file