> For the complete documentation index, see [llms.txt](https://docs.rulecube.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rulecube.com/v2.5/how-to-guides/ruleset-development/set-the-input-for-a-ruleset.md).

# Set the Input for a Ruleset

## Introduction

This guide explains how to create the input for a ruleset.&#x20;

**Inputs** are the raw materials of rulesets because the ruleset acts upon them. If the ruleset is a calculation, then the inputs are the values that go into the calculation.

### Basic and advanced settings for an input

Each input has **basic settings** like `Name` and `Type`, and **advanced settings** like `Required`. Furthermore, the settings for an input vary according to its type.&#x20;

<details>

<summary>List of possible settings for an input with their characteristics</summary>

* **Name**\
  The name for the input.
* **Output**\
  Whether the input is also available as output for the ruleset.
* **Type**\
  This setting specifies the input type to one of these types:
  * `any`\
    As its name implies, an `any` input can contain any type of input.&#x20;
  * `number`\
    This type includes negative values and numbers with decimals.
  * `boolean`\
    This type expects the values `true` or `false`.
  * `string`\
    This type can contain any text, including numbers.
  * `date`\
    This type expects a date in `mm/dd/yyyy` format.
  * `enum`\
    For this type, you can set a list of possible values. For example, `good`, `bad`, `ok`.
  * `array`\
    This type contains a one-dimensional array of values. For example, this JSON array:<br>

    ```json
    {
      "AgeScale": [
        6,
        12,
        18
      ]
    }
    ```
  * An entity that you created yourself.
* **Sub type**\
  This setting only applies if the **Type** is `array` and sets the type for the array elements.
* **Possible values**\
  This setting only applies if the **Type** is `enum` and sets the possible values for the input.
* **Default value**\
  If you provide this setting, Rulecube prefills the input with the value for this setting.
* **Different input name** (Advanced settings)\
  This setting goes along with the **Original input name** setting and sets whether the (original) input has a different name that needs to be mapped. For example, input names with a hyphen (-) are not allowed, but if a JSON input contains a key with a hyphen, this setting enables mapping the JSON name to the input name. Suppose a JSON key is named `e-mail`; then it can be assigned to an input called `email`.
* **Original input name** (Advanced settings)\
  Elaborating on the previous setting, this setting contains the original input name. And elaborating on the previous example, it would contain `e-mail` referring to the original JSON key.
* **Required** (Advanced settings)\
  Whether the input is required or not.
* **Min.** (Advanced settings)\
  The minimum value or length of an input. For example, for a `number`, you could set the value to be at least `25`. And for a `string`, you could set the length must be at least `4` characters.
* **Max.** (Advanced settings)\
  The maximum value or length of an input. For example, for a `number`, you could set the value to be up to `1200`. And for a `string`, you could set the length to be a maximum of `50` characters.
* **Strict** (Advanced settings)\
  This setting collaborates with **Min.** and **Max.** and if checked, the input must be within the min-max range. Otherwise, Rulecube returns an error. If this setting isn't checked and you supply an out-of-range value for the input, Rulecube automatically truncates the value to be within the range.
* **Label**\
  This label is shown in the *Sandbox* when you try out the ruleset and enables you to have an explaining label for the input while keeping your input name short or letting it conform to a naming convention.
* **Description**\
  A description of the input for later reference or your colleagues.

</details>

## Before you begin

* If you want to create an input based on an entity, you must create the corresponding entity first.

## General procedure

1. Open the ruleset where you want to create the input or create a new ruleset.
2. Click the **+** sign behind **Input** from the left menu.\
   ↳ The **Input details** page opens.
3. In the **Name** field, enter the name for the input.
4. In the **Type** list, select the input type.\
   ↳ Rulecube shows the settings that apply to the chosen type.
5. If you need additional settings for the input, enter them in the corresponding fields.
6. If you need advanced settings, click **Advanced settings**, then enter the settings you need.
7. If you're done, click **Save**.

{% hint style="info" %}
You can also clone an existing input with the following steps:

1. Open an existing input.
2. Click **Clone**.\
   ↳ Rulecube creates a clone of the input and names it with the `_copy` extension.
3. Modify the input name as desired and change/enter other settings if necessary.
   {% endhint %}

## Specific procedures

Let's look at examples for creating `enum` and `array` inputs because of the settings variations of input types.

### Create an `enum` input

Let's assume that you want an input that must be one of the values: `north`, `east`, `south`, `west`.

1. Open the ruleset where you want to create the input.
2. Click the **+** sign behind **Input** from the left menu.\
   ↳ The **Input details** page opens.
3. In the **Name** field, enter `CustomerArea`.
4. In the **Type** list, select **enum**.\
   ↳ Rulecube adds the **Possible values** setting to the details page.
5. In the Possible values field, enter `north`, `east`, `south`, `west`.
6. Click **Advanced settings** and select the **Required** checkbox.
7. In the Label field, enter `The area where the customer is based`.
8. Click **Save**.
9. Try out the ruleset. Note that the possible values are collected in a list box.

#### Optional: call the ruleset via its API to simulate an error

Call the ruleset API from [Postman](/v2.5/how-to-guides/call-a-ruleset-via-its-api-from-postman.md) or [JavaScript](/v2.5/how-to-guides/use-a-ruleset-from-your-software.md) and supply an invalid value for `CustomerArea` to see how the API responds.

### Create an `array` input

Let's say you need to process a sequence of 6 test scores for each participant in a course.

1. Open the ruleset where you want to create the input.
2. Click the **+** sign behind **Input** from the left menu.\
   ↳ The **Input details** page opens.
3. In the **Name** field, enter `TestScores`.
4. In the **Type** list, select **array**.\
   ↳ Rulecube adds the **Sub type** setting to the details page.
5. Leave the **Sub type** list to **number**.
6. Click **Advanced settings** and select the **Required** checkbox.
7. In the **Min. length** field, enter `6`.  And do the same for **Max. length**.
8. Select the **Strict** checkbox.\
   ↳ Now the array requires exactly 6 test scores (elements).
9. Click **Save**.

#### How to address an array element

You can select a specific array element by its index, like in the following example:

```javascript
TestScores[2]
```

Be aware that the array index starts at `0` for the first element. So, the example selects the third score from the array.

## Additional resources

* How-to Guide: [Create a Rule](/v2.5/how-to-guides/ruleset-development/create-a-rule.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.rulecube.com/v2.5/how-to-guides/ruleset-development/set-the-input-for-a-ruleset.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.
