Validations
Check the final result of an IDP template with code, API call or robot validations: fields, the pass rule for each kind, robot input mapping and failure reasons.
Validations
Validations are checks the template's final result has to pass. They form a list run top to bottom, with the card controls described in Pipeline, and each one passes or fails the result.
| Kind | What it does |
|---|---|
| Code | Passes or fails the result with a script. |
| API | Sends the result to an API that answers whether it passes. |
| Robot (RPA) | Runs a real robot, including in tests, and uses its answer as the verdict. |
Every validation has a Name, shown on the card and in the results, for example "Total matches the items" or "Company ID is active".
What validations receive
All validations receive the same final result: the output of the last post-processing step or, without post-processing, the extraction result.
Every enabled validation runs, even when one of them fails. A failure does not stop the pipeline or make the run fail: the run ends as Finished, and the result records which validations passed and, for the failed ones, the reason. In the Playground, the Validations tab shows the score, for example "2/3 passed". Disabled validations do not run.
With no validations, every result is accepted.
Code validation
The Code validation runs a script in Node.js (default) or Python with the same contract as the post-processing code steps: input holds the final result, and the verdict is the value assigned to output. In Node.js, params carries the parameters sent with the call.
Value of output | Verdict |
|---|---|
true / True | Passed. |
false / False | Failed. |
{ passed, reason } (in Python, {"passed": bool, "reason": str}) | Passed or failed according to passed; reason explains the failure. |
| Any other value | Failed, with a reason that shows the value received. |
If the script throws an error, the validation fails with the error message. A validation with no code always fails. Reasons longer than 500 characters are cut.
const sum = input.itens.reduce((total, item) => total + Number(item.valor), 0);
output = sum === Number(input.total)
? true
: { passed: false, reason: "Total does not match" };
API validation
The API validation makes an HTTP request to an endpoint of yours, which decides whether the result passes.
| Field | Default | Description |
|---|---|---|
| Endpoint | POST | The method — GET, POST, PUT, PATCH or DELETE — and the URL called. |
| Headers | — | Name and value pairs sent with the request, for example an authentication token. |
The request is sent with Content-Type: application/json, and the final result goes in the body, as JSON, except for GET and DELETE, which have no body.
Any 2xx response passes. Any other status fails with the reason "A API respondeu com status N" (the API answered with status N); a connection failure fails with the error message. The API's response is recorded in the validation's result.
Headers are saved in the template and go along when it is exported. See General.
Robot validation
The Robot (RPA) validation triggers a workspace robot and uses its answer as the verdict. The robot really runs on every run, including in the Playground, Simulate API and the evaluation sets.
| Field | Default | Description |
|---|---|---|
| Robot | — | The robot to run, searched by name. |
| Robot inputs | — | For each input the robot declares, the path of the value it receives. |
| Timeout (seconds) | 300 | From 1 to 840. If the robot doesn't answer within this time, the validation fails. |
Robot inputs
The robot receives data through the inputs it declares with the Get Webhook inputs action. For each input, enter a path starting from:
payload— the final result, for examplepayload.cnpjorpayload.issuer.name;params— the parameters sent with the call to the template, for exampleparams.customer.
The field suggests paths from the last Playground run. An input whose path does not exist in the result is not sent. If the robot declares no inputs, it receives no data from the result.
Robot reply
The robot must reply with an object { passed, reason }, where passed is true or false and reason explains the failure, for example with the Reply Webhook action. Without that reply, the validation always fails. When the chosen robot has no such action, or its reply does not declare the passed field, the card shows a warning.
The timeout never goes beyond the time the template run still has left; if less than 5 seconds remain, the validation fails as timed out.
Failure reasons
Besides passed: false, the robot validation fails in these cases:
| Reason | When it happens |
|---|---|
| Robot not configured | No robot was selected for the validation. |
| Robot not found | The robot does not exist, is inactive or belongs to another workspace. |
| Device unreachable | The robot's device is offline or unreachable. |
| Robot error | The robot finished with an error. |
| No verdict | The robot finished without returning a verdict with passed. |
| Timed out | The robot did not answer within the timeout. |
| Not in the plan | The workspace plan does not include running robots through webhooks. |