Skip to main content

Defining Inputs

Inputs define what data your feature needs to run. Ductape validates incoming data against your input schema before executing the feature.

Basic Structure

Each input field needs a type and can optionally have length constraints:

input: {
email: { type: 'EMAIL_STRING' },
username: { type: 'STRING', minlength: 3, maxlength: 20 },
age: { type: 'INTEGER' }
}

Data Types

TypeWhat It AcceptsExample
STRINGAny text"Hello world"
EMAIL_STRINGValid email format"user@example.com"
NOSPACES_STRINGText without spaces"username123"
NUMBER_STRINGNumber as text"12345"
DATE_STRINGDate as text"2024-01-15"
INTEGERWhole numbers42
FLOATDecimal numbers3.14
BOOLEANTrue or falsetrue
UUIDUUID format"550e8400-e29b-41d4-a716-446655440000"
ARRAYList of items[1, 2, 3]
OBJECTJSON object{ "key": "value" }

Array Types

For typed arrays, use these:

TypeContents
STRING_ARRAYArray of strings
INTEGER_ARRAYArray of integers
FLOAT_ARRAYArray of decimals
BOOLEAN_ARRAYArray of booleans
UUID_ARRAYArray of UUIDs

Length Constraints

Add minlength and maxlength to enforce size limits:

input: {
password: {
type: 'STRING',
minlength: 8, // At least 8 characters
maxlength: 100 // No more than 100 characters
},
tags: {
type: 'STRING_ARRAY',
minlength: 1, // At least 1 item
maxlength: 10 // No more than 10 items
}
}

Complete Example

await ductape.features.create({
name: 'Create User',
tag: 'create-user',
description: 'Creates a new user account',
input_type: 'JSON',
input: {
email: { type: 'EMAIL_STRING' },
username: { type: 'NOSPACES_STRING', minlength: 3, maxlength: 20 },
password: { type: 'STRING', minlength: 8 },
age: { type: 'INTEGER' },
newsletter: { type: 'BOOLEAN' }
},
sequence: [/* ... */],
output: {/* ... */}
});

When running this feature:

// This will pass validation
await ductape.features.run({
env: 'prd',
product: 'my-app',
feature_tag: 'create-user',
input: {
email: 'john@example.com',
username: 'johndoe',
password: 'securepass123',
age: 25,
newsletter: true
}
});

// This will fail - email is invalid
await ductape.features.run({
env: 'prd',
product: 'my-app',
feature_tag: 'create-user',
input: {
email: 'not-an-email', // Invalid!
username: 'johndoe',
password: 'securepass123',
age: 25,
newsletter: true
}
});

Tips

  1. Keep inputs flat - Nested objects aren't supported; use separate fields instead
  2. Use specific types - EMAIL_STRING catches invalid emails automatically
  3. Set reasonable limits - Prevent abuse with minlength and maxlength
  4. Use descriptive names - customerEmail is clearer than e

See Also