githubEdit

mathBlock

The mathBlock lets you to define calculations on document data in mathematical notation to be performed directly, without the need or optionally with limited use of coding.

1.1 Properties

Input Schema

The input document schema.Required

Net_ERR_Calculation

Output Schema

The output (results) document schema. Optional. If not specified, the input schema is used.

Net_ERR_Calculation

Unsigned VC

Allows the use of a simple JSON document as input (no VC-style proofs required)

Checked/Unchecked

Expression

The set of formulas and commands executed at policy runtime.

formulas defined

1.1.1 Expression definition

Expression definition is guided by a wizard with in-place test execution, allowing policy authors to define formulas and the data they apply to at policy runtime. It includes the following sections:

1. Inputs

Use this section to map fields from the input document to short variable names that you can reference in formulas.

circle-info

Note 1: A variable in a formula may reference data from any field in any document, not just the input document itself. However, the referenced document must be associated with the input document (i.e. be part of its ‘relationships' chain). If no such relationship exists, the value cannot be resolved at runtime, which may lead to unpredictable or undefined behavior.

circle-info

Note 2: Source documents are located based on schema matching. If multiple related documents match the required schema, the system selects the nearest (most recent) document in the relationships chain as the data source.

2. Formulas

This section provides UI to defined formulas using standard mathematical notation and/or LateX or MathJSON formats.

2.1 Formula defintion

To define a formula, complete the following steps:

  • Specify the formula name.

  • Add () after the formula name and list any parameters inside. Separate parameters with a comma (,).

  • Create the expression using math notation or an alternative format (LaTeX, MathJSON).

In some cases, switching between math notation, LaTeX, and MathJSON can help you verify or correct a formula. You can edit in any format; the system automatically synchronizes changes across formats.

You can reuse defined formulas in other formulas (by name) and in the code on the Advanced tab.

circle-check
circle-check

2.2 Variables

When parentheses are not included after the name (e.g., x vs. x()), it is treated as a variable definition. The variable value is calculated at initialization time.

2.3 Code (advanced)

For complex scenarios where formulas are not sufficient for the required data transformations, use the Advanced (Optional) tab to add logic in JavaScript.

In code, you can reference all defined formulas and variables by name.

3. Outputs

Use this section to configure which document fields receive the results of calculations from the previous sections.

In this section, you can reference input/output fields and variables only. Formulas can be referenced only in the Formulas section.

4. Tabs

For convenience Inputs\Formulas\Outputs can be visually partitioned using tabs. This partitioning has not impact on the functionality of the policy, it is used to ease UI navigation by policy authors.



4.1 Creation

4.2 Renaming

Tabs can be renamed as required.

4.3 Deletion

Tabs can be deleted.

4.4 Navigation

5. Test

After you define formulas, you can validate them using the Test section. Complete the following steps:

a. Inputs

To begin testing, specify the main Input Document.

If required, add additional documents associated with the input document. Make sure these documents are part of the main Input Document’s relationships chain.

Provide input data in a document using one of the following three options:

  • Use a form that matches the input schema.

  • Provide JSON.

  • Upload a file (the file must contain valid JSON).

b. Select Test

c. Results

Guardian displays test results for each element

1.2 Visualization at Policy runtime

Once a policy is published, Guardian generates Formula-Linked Definitions (FLDs) for all mathBlock elements in the policy. You can explore these the same way as standard FLDs.

circle-exclamation

Last updated

Was this helpful?