Input and output data
Note
This section describes how to edit the specification in an HTML/JS/CSS editor. You can also learn how to edit the specification in the Template Builder.
In the Specifications field, you set parameters for input and output data. These settings will be valid for all tasks in the project.
In the specification, add fields for the data used in the task or for the data you need in the results. Reference these fields when you configure the interface.
Don't repeat the input data in the output data. You will receive all data, including the input, in the results.
How to edit the specification
Note
Specification editing is available only when the Define data specification manually option is enabled.
There are two ways to edit the specification in project settings: using either regular mode or JSON mode. JSON mode gives you more options — you can hide input data and use regular expressions to validate output data.
To add a field in the regular mode, click Add field.
To edit an existing field, hover over the field and click
To switch modes, click
Examples of fields:
-
String of a certain length
"my_string": { "type": "string", "required": true, "min_length": 10, "max_length": 100 }
-
Only Latin letters and numbers
"my_en_string": { "type": "string", "required": true, "min_length": 10, "max_length": 100, "pattern": "[a-zA-Z0-9]+" }
-
Only Cyrillic letters and numbers
"my_ru_string": { "type": "string", "required": true, "min_length": 10, "max_length": 100, "pattern": "[а-яА-Я0-9]+" }
-
Letters and characters without numbers
"my_number_string": { "type": "string", "required": true, "min_length": 10, "max_length": 100, "pattern": "[^0-9]+" }
-
Link from a specific site
"my_url": { "type": "string", "required": true, "pattern": "(?:http(?:s)?:\\/\\/)?(?:[a-zA-z-]+(\\.)+)*(?:yandex\\.ru){1}(\\/|\\/[a-zA-Z-\\._~:/\\?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=]+)?" }
-
Phone number with the
+
,-
and space characters"my_phone_string": { "type": "string", "required": true, "pattern": "\\+?[0-9\\s-]{4,}" }
-
Email with the
@
,-
and.
characters"my_mail_string": { "type": "string", "required": true, "pattern": "[a-zA-Z]{1}[a-zA-Z0-9\\.\\-_]+@[a-zA-Z0-9\\.\\-_]+\\.[a-zA-Z]{2,}" }
-
Month
"my_month_string": { "type": "string", "required": true, "allowed_values": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October" "November", "December"] }
"my_url": {
"type": "url",
"required": true
}
"my_boolean": {
"type": "boolean",
"required": true
}
-
Integer from the specified range:
"my_integer": { "type": "integer", "required": true, "min_value": 1, "max_value": 100 }
-
Integer with a list of allowed values:
"my_integer": { "type": "integer", "required": true, "allowed_values": [10, 20, 30] }
-
Fractional number:
"my_float": { "type": "float", "required": true, "min_value": 10.11, "max_value": 65.51 }
-
A number with 0, 1, or 2 decimal places.
To do this, choose the string type and use regular expression for validation. Note that the decimal separator is a comma:
"my_mail_string": { "type": "string", "required": true, "pattern": "^([0-9]+)(,([0-9]){1,2})?$" }
"my_file": {
"type": "file",
"required": true
}
"my_file_array": {
"type": "array_file",
"required": true,
"max_size": 5
}
"my_coordinates": {
"type": "coordinates",
"required": true
}
"my_json": {
"type": "json",
"required": true
}
The string the Toloker can't access:
"my_string": {
"type": "string",
"hidden": true
}
Parameter |
Parameter in JSON |
Overview |
Name |
|
Field ID. Only Latin letters, numbers, hyphens, and underscores are allowed. |
Type |
|
Data type:
For arrays, add the |
Required |
|
Whether the field must be filled when uploading the tasks for the input data. Whether the Toloker's response is required in the output data. By default, fields are optional — |
Hidden |
|
Allows you to hide data from the Toloker. If this is not done, Tolokers can get the field value programmatically. You can configure this parameter in JSON mode. For example, you can hide the By default, the field is visible — Warning Hidden fields are not available in the task interface, even through JS or the template code in the constructor. |
Array |
|
Array of objects of the same type. Used, for example, for multiple photos uploaded by a Toloker.
In JSON mode, there is a separate data type for the array. For example: |
Min size |
|
Minimum number of items in the array. |
Max size |
|
Maximum number of items in the array. |
Allowed values |
|
Allowed values for string, integer, float and boolean data types. |
Min length |
|
Minimum length of the string. |
Max length |
|
Maximum length of the string. |
Min value |
|
Minimum values for float and integer numbers. |
Max value |
|
Maximum values for float and integer numbers. |
Current location |
|
Saving the Toloker's current coordinates ( The default value is |
Pattern |
|
Regular expression that the string must match. You can configure this parameter in JSON mode. |
Recommendations
-
If you edit a required field, the changes apply only to new task pools. For example, if you need to fix an error in a project, clone the pool or create a new one. Existing task pools will continue using the previous version of the project.
-
In the output, use value validation and don't forget to mark the field as required if the Toloker has to fill it in.
-
Hidden fields are intended only for requesters and are not available in the task interface. The values of hidden fields can't be used either in the JS code or in the template constructor.
Let's say you pass product data (like articles or batch numbers) that Tolokers don't need in order to complete the task. Or you are moderating comments and you need the authors' personal data in the results for further data processing, but the Tolokers shouldn't have access to personal data.
To create a hidden field, add it to the specification yourself and then add the
"hidden": true
parameter to this field in JSON mode. You should do this in Toloka when configuring your project. The hidden field remains when the specification is re-generated using the Template Builder.
What's next
-
Learn more about how to set up a project:
See also
Troubleshooting
You can find an example of the task template for selecting image groups at this link. The input and output data, as well as a fragment of the instructions, are in the comments to the project.
To validate the input data format, you can use the output field type, specifying the acceptable or minimum/maximum values. For example, create an output field for the taxpayer number with the “string” type and enter its minimum and maximum length (like 10 and 12). To use a more sophisticated validation in the template, use RegExp.
To enter a date, you can add a calendar to the task interface. See an example of a calendar.
You can use different image sizes.
You can't use a range as a fixed value.
If you pass texts to the input data, you can upload 2 different tasks to the pool: pass Text 1 in the INPUT: <input field name>
field of Task 1. In Task 2, use this field to pass Text 2.
If the text is in the HTML block of the task template, then clone the project. To limit a Toloker to doing only one task in your project, use the Submitted responses rule. You can assign a skill or ban the Toloker after they submit one response.