Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intrinsic function: States.ArrayContains #476

Open
meenahoda opened this issue Oct 17, 2023 · 0 comments
Open

Intrinsic function: States.ArrayContains #476

meenahoda opened this issue Oct 17, 2023 · 0 comments

Comments

@meenahoda
Copy link
Member

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 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant