Validation and control flow reference
This page lists every field and option. The overview shows what it does and a first example.
The validations: block controls if a resource runs and what it accepts. It operates before the action: before an LLM call, an HTTP request, or a script.
Set per resource.
# resources/example.yaml
validations:
methods: [POST] # skip unless method matches
routes: [/api/v1/data] # skip unless route matches
headers: [Authorization] # skip unless header present
params: [q] # skip unless param present
skip:
- get('mode') == 'dry-run' # skip silently (no error)
check:
- get('q') != '' # fail with error below if false; a missing q equals ''
error:
code: 400
message: "q is required"Fields summary:
| Field | Logic | Behavior when condition triggers |
|---|---|---|
methods / routes | match | skip silently if no match |
headers / params | match | skip silently if no match |
skip | OR - any true | skip silently |
check | AND - all must be true | return error to caller |
Skip conditions
Use skip conditions to skip a resource, based on runtime values.
Basic usage
# resources/conditional-resource.yaml
actionId: conditionalResource
name: Conditional Resource
validations:
skip:
- get('skip') == true
- get('mode') == 'dry-run'
chat:
context:
prompt: "{{ get('q') }}"How it works
Any true condition skips the resource silently. It produces no output, but its slot in the dependency graph stays, so downstream resources can still reference it. Use get() to access any data source in skip conditions.
Common patterns
# resources/example.yaml
validations:
skip:
# Skip if flag is set
- get('skip') == true
# Skip if no query parameter
- get('q') == '' || get('q') == null
# Skip based on item value (in items iteration)
- get('current') == 'skip_this'
# Skip if previous resource failed
- get('previousResource') == nullPreflight checks
Preflight checks validate inputs before resource execution begins. If a condition fails, kdeps stops the resource with a custom error.
Basic usage
# resources/validated-resource.yaml
actionId: validatedResource
name: Validated Resource
validations:
check:
- get('q') != ''
- get('userId') != null
- len(get('q')) > 3
error:
code: 400
message: Query parameter 'q' is required and must be at least 3 characters
chat:
context:
prompt: "{{ get('q') }}"How it works
All check conditions must pass (AND logic). If one fails, execution stops and the caller gets the configured error, before any LLM call or HTTP request.
Check expressions
# resources/example.yaml
validations:
check:
- get('q') != ''
- get('userId') != null
- type(get('age')) == 'int' || type(get('age')) == 'float'
- get('age') >= 18
- len(get('email')) > 5
- get('email') contains '@'
- get('status') == 'active' || get('status') == 'pending'
- get('previousResource') != null
error:
code: 400
message: "Validation failed"Error response
When a check validation fails:
{
"success": false,
"error": {
"code": 400,
"message": "Query parameter 'q' is required and must be at least 3 characters"
}
}Route and method restrictions
Limit which HTTP requests can trigger a resource.
Basic usage
# resources/api-resource.yaml
actionId: apiResource
name: API Resource
validations:
methods: [GET, POST]
routes: [/api/v1/data, /api/v1/query]
chat:
context:
prompt: "{{ get('q') }}"How it works
- Resource only executes if both conditions match
- If restrictions do not match, kdeps skips the resource silently
- An empty array accepts all values
Method restrictions
# resources/example.yaml
validations:
methods: [GET] # only GET
methods: [GET, POST] # GET and POST
# omit to allow all methodsRoute restrictions
# resources/example.yaml
validations:
routes: [/api/v1/users] # single route
routes: [/api/v1/users, /api/v1/profiles] # multiple routes
# omit to allow all routesCombined example
# resources/example.yaml
validations:
methods: [POST]
routes:
- /api/v1/create
- /api/v1/update
chat:
context:
prompt: "Create: {{ get('data') }}"Input validation
Validate the structure and content of request data using required, rules, and expr.
Basic usage
# resources/validated-input.yaml
actionId: validatedInput
name: Validated Input
validations:
required:
- userId
- action
properties:
userId:
type: string
minLength: 1
action:
type: string
enum: [create, update, delete]
age:
type: number
minimum: 18
maximum: 120
chat:
context:
prompt: "{{ get('action') }} user {{ get('userId') }}"Validation syntax
kdeps supports multiple syntaxes for field validation:
properties (map format)
# resources/example.yaml
validations:
required: [email, name]
properties:
email:
type: string
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
name:
type: string
minLength: 1rules (array format)
# resources/example.yaml
validations:
required: [email, name]
rules:
- field: email
type: string
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
- field: name
type: string
minLength: 1fields (alternative map format)
# resources/example.yaml
validations:
required: [email, name]
fields:
email:
type: string
name:
type: string
minLength: 1Validation rules reference
| Rule | Type | Description |
|---|---|---|
required | array | List of required fields |
properties / fields / rules | object/array | Field-specific validation rules |
type | string | string, number, integer, boolean, object, array, email, url, uuid, date |
minLength | number | Minimum string length |
maxLength | number | Maximum string length |
minimum / min | number | Minimum numeric value |
maximum / max | number | Maximum numeric value |
enum | array | Allowed values |
pattern | string | Regex pattern (for strings) |
minItems | number | Minimum array items |
maxItems | number | Maximum array items |
message | string | Custom error message for this field |
Custom expression rules
# resources/example.yaml
validations:
required: [email, password, confirmPassword]
properties:
email:
type: string
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
password:
type: string
minLength: 8
confirmPassword:
type: string
expr:
- "get('password') == get('confirmPassword')"
- "get('email') contains '@'"
chat:
context:
prompt: "Process user: {{ get('email') }}"Allowed headers and parameters
Limit the headers and query parameters that requests can use.
Allowed headers
# resources/example.yaml
validations:
headers:
- Authorization
- Content-Type
- X-API-Key
chat:
context:
prompt: "{{ get('q') }}"get() cannot read headers that are not in this list.
Allowed parameters
# resources/example.yaml
validations:
params:
- q
- userId
- action
chat:
context:
prompt: "{{ get('q') }}"get() cannot read parameters that are not in this list.
Combined example
# resources/example.yaml
validations:
methods: [POST]
routes: [/api/v1/secure]
headers:
- Authorization
- Content-Type
params:
- action
chat:
context:
prompt: "Secure action: {{ get('action') }}"Execution order
Request
v headers / params -> filter inaccessible keys
v skip conditions -> skip if any true
v methods / routes -> skip if no match
v check + error -> abort with error if any false
v required/rules/expr -> abort with 422 if invalid
v Execute ResourceUse cases
- Reject a bad request before it reaches an LLM or an external API, so a missing field costs nothing (
check+error). - Skip a resource when its work is not needed this run - a cache hit, an empty input, a feature flag off (
skip). - Scope a resource to specific HTTP methods and routes so one workflow serves several endpoints (
methods,routes). - Enforce an input schema (types, required fields, ranges) with a 422 response on failure (
required,rules,properties,expr).
See also
- Validation examples - best practices and examples
- Expressions - expression syntax for conditions
- Resources overview - resource structure
- Unified API - using
get()in validations - Workflow configuration - route configuration
