Skip to main content

Defining Inputs

Feature inputs in Ductape allow you to define and enforce validation rules for data that flows into a feature. Expected in JSON format, these inputs enable you to specify data types and apply constraints like minimum and maximum length, ensuring data consistency and reliability.

Basic Format for Defining Data Inputs

The basic structure for defining a feature input includes specifying the data type, along with optional constraints like minimum and maximum length. This structure is expressed as follows:

{
[key]: {
type: DataTypes, // Required: Specifies the expected data type
minlength: number, // Optional: Minimum length of the value
maxlength: number, // Optional: Maximum length of the value
}
}

Example of a Feature Input Definition

Here’s an example of how feature inputs can be defined in a Ductape feature:

{
username: {
type: DataTypes.NOSPACES_STRING, // Username must be a string without spaces
minlength: 3, // Minimum length of 3 characters
maxlength: 10, // Maximum length of 10 characters
},
email: {
type: DataTypes.EMAIL_STRING, // Must follow a valid email format
},
house_number: {
type: DataTypes.INTEGER // Expected to be an integer
},
country: {
type: DataTypes.STRING // Free-form text for country name
},
state: {
type: DataTypes.STRING // Free-form text for state name
}
}

Note: The current version of the Ductape SDK supports only flat objects for inputs, meaning nested objects are not accepted.

Available DataTypes Options

The following DataTypes are available for defining feature inputs:

TypeDescription
STRINGFree-form text
NOSPACES_STRINGString without spaces
EMAIL_STRINGString in a valid email format
DATE _STRINGString in a valid date format
NUMBER_STRINGString representing a number
INTEGERInteger value
DATEDate value
FLOATFloating-point number
DOUBLEDouble-precision floating-point number
UUIDUniversally Unique Identifier (UUID)
ARRAYArray of items
OBJECTJSON object
BOOLEANBoolean value (true or false)

By defining inputs with these options, you ensure that data flowing into your feature is structured, validated, and matches the expected format. This prevents errors due to invalid data and maintains consistency in feature input handling.