# Real-time validation

### How it works

![](/files/-MFTeFcS6w-_gZU3YfDA)

## Getting started

To upload documents under the conditional validation workflow, a few changes to the standard `fileupload` form-data parameters are required:

* Specify the validation workflow type by setting: `workflowId=validate`
* Specify the `fieldSet` or `fieldSets` parameter to predict against
* Configure the `workflowOptions` according to the required validation rules

{% hint style="info" %}
Validation workflows are a `BETA` feature and subject to change.\
This guide is under-construction.
{% endhint %}

![Sample Postman configuration for a file-upload with the validate workflow](/files/-MFdZtz4w5iXQqg06tbE)

#### Validation Parameters

Workflow options are strings which contain a JSON-formatted object that controls how the steps in the validation workflow are executed. Here's a sample `workflowOptions` string which validates the confidence of the `bpay.crn` field:

```javascript
{
   "prediction":{
      "fieldset": "sypht.bpay",
      "conditions":[
         {
            "type": "field-confidence-range",
            "field": "bpay.crn",
            "min": 0.5
         }
      ],
      "createTask":{
         "submit": true,
         "priority": 1
      }
   }
}
```

For the sample above, extractions which include a `bpay.crn` with confidence less than `0.5` will produce a validation task for the `sypht.bpay` specification.

{% hint style="info" %}
&#x20;The `fieldset` specified to validate in the `workflowOptions` should be contained in the `fieldSets` requested to predict against on the base `/fileupload/` request
{% endhint %}

The full set of validation conditions includes:

* `field-confidence-range`
  * Validates whether a given field's prediction condidence value falls within an expected range.
  * Predictions with values outside the allowed range will trigger validation of the field.
  * Typically used to identify and review low confidence predictions.
  * **Required**
    * `field` - Id of the field to validate
  * **Options**
    * `min` - The minimum value for the predicted field confidence
      * Inclusive
      * Default = `null` for no minimum
    * `max` - The maximum value for the predicted field confidence
      * Inclusive
      * Default = `null` for no maximum
* `field-value-range`
  * Validates whether a given field's normalised value falls within an expected range.
  * Predictions with values outside the allowed range will trigger validation of the field.
  * **Required**
    * `field` - Id of the field to validate
  * **Options**
    * `min` - The minimum value for the predicted field confidence
      * Inclusive
      * Default = `null` for no minimum
    * `max` - The maximum value for the predicted field confidence
      * Inclusive
      * Default = `null` for no maximum
* `field-present`
  * Verifies the presence of a value for a field on a document.
  * Documents missing values for this field will trigger validation of the field.
  * **Required**
    * `field` - Id of the field to validate

{% code title="Response" %}

```bash
{
    "fileId": "815c63f6-6152-467c-9182-f07223d057cb",
    "uploadedAt": "2020-08-20T03:19:07.319Z",
    "status": "RECEIVED"
}
```

{% endcode %}

#### Tasks

<https://app.sypht.com/tasks>

![](/files/-MFTdkntVkwhJAXxPnbt)

#### Collecting results

While tasks are in progress, the results endpoint will block requests for up-to 30 seconds and return an `IN PROGRESS` status.

```javascript
GET https://api.sypht.com/result/final/815c63f6-6152-467c-9182-f07223d057cb

Response
{
    "fileId": "1111111-6152-467c-9182-f07223d057cb",
    "status": "IN PROGRESS"
}

```

One complete, results will be returned normally.

```javascript
Response (once prediction/ is complete)
{
    "fileId": "1111111-6152-467c-9182-f07223d057cb",
    "status": "FINALISED",
    "results": {
        "timestamp": "2020-08-20T03:30:09.703Z",
        "fields": [
            {
                "name": "vehicle.odometerKm",
                "value": "148500",
                "confidence": 0.9958282699555642,
                ...
            },
            ...
        ]
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sypht.com/sypht/workflows/validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
