# START

<figure><img src="https://2784301415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZKEXabVqsSUGdA72pv7B%2Fuploads%2Fh2ykHc0iKkWCvnjTOIji%2Fimage.png?alt=media&#x26;token=baa7fdc8-45bc-4be7-92cf-215cc9755bdb" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**START node is obligatory for every scenario!**
{% endhint %}

This node defines input variables for the scenario. Variables can be defined manually in a settings panel or imported in a JSON or CSV format. It is also possible to define validators for specified input variables, which ensures that proper values are submitted.&#x20;

Example of input variables in CSV format:

```csv
true;var3;DOUBLE;;
true;var4;aa#bb#cc;;
```

Columns of this CSV contain, respectively, an information whether the variable is required, variable name, type, description and tags.

Available types: STRING, DOUBLE, INTEGER, DICTIONARY, MAP, VECTOR, BOOLEAN

<figure><img src="https://2784301415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZKEXabVqsSUGdA72pv7B%2Fuploads%2FIlOLtsslGAIjILr6Luop%2Fimage.png?alt=media&#x26;token=0c443dc7-b202-4fad-a08a-6ea4f3a2d699" alt="" width="287"><figcaption></figcaption></figure>

Parameters of the node:

* Variables (adding / removing))
  * Variable type, name, description (shown as a field description in a form)&#x20;
  * Possible values of dictionaries
  * required / non-required
* Validators
  * Define validator per variable; multiple validators available
  * If the validation fails, the engine returns an error (HTTP 400)
  * We can define a custom error description providing it as a Groovy/Python/R script result
  * Any returned value other than logical *true* is treated as failure of the validation
* Variable definition import from JSON file

Example of validation code (verification of variable length):

```groovy
if ((object as String).length()!=32) {
    result=’Error. Incorrect string length.’
}
else {
    result=true
}
return result
```

## Complex variable validation

In case we need validate complex types (MAP, VECTOR) there is validation API based on JSON Schema (<https://json-schema.org/>) or Swagger / OpenAPI.

In case of successful validation, we return the boolean value true, otherwise we return a text containing an error message. The message will be returned in the API response.

### JSON Schema validator example

```groovy
import com.algolytics.sce.core.scenario.validator.JsonSchemaValidator
def schemaStr = '''
    <JSON Schema for the variable>
'''
errors = JsonSchemaValidator.validate(object, schemaStr)
if (errors.size() > 0) {
    return errors.toString()
} else {
    return true
}
```

### Swagger validator example

```groovy
​import com.algolytics.sce.core.scenario.validator.*
import org.openapi4j.core.validation.ValidationSeverity
def schemaStr = '''
    <Swagger for the variable>
'''
validationData = OpenApi3Validator.validateForJson(object, schemaStr, 'AlgolyticsRequestZonk')
if (validationData.isValid()) {
    return true
} else {
    return validationData.results().items(ValidationSeverity.ERROR).toString()
}
```
