Skip to content

Intrinsic function: States.ArrayContains #476

@meenahoda

Description

@meenahoda

States.ArrayContains

Description from https://states-language.net/#appendix-b

Use the States.ArrayContains intrinsic function to determine if a specific value is present in an array. For example, you can use this function to detect if there was an error in a Map state iteration.

This intrinsic function takes two arguments. The first argument is an array, while the second argument is the value to be searched for within the array.

Input validation

You must specify an array as the input value for function's first argument.
You must specify a valid JSON object as the second argument.
The input array can't exceed Step Functions' payload size limit of 256 KB.
For example, given the following input array:

json{ "inputArray": [1,2,3,4,5,6,7,8,9], "lookingFor": 5 }
You could use the States.ArrayContains function to find the lookingFor value within the inputArray:

json"contains.$": "States.ArrayContains($.inputArray, $.lookingFor)"
Because the value stored in lookingFor is included in the inputArray, States.ArrayContains returns the following result:

json{"contains": true }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions