dash.assert.strsInList

Throw error if strings are not in a list of allowed strings


Syntax



Description

k = dash.assert.strsInList(strings, list)

Checks if all elements in strings are members of list. If not, throws an error. If so, returns the indices of each string in the list.

k = dash.assert.strsInList(strings, list, name, listName)

Use custom names for the strings and list in the thrown error message.

k = dash.assert.strsInList(strings, list, name, listName, idHeader)

Use a custom header in thrown error IDs.


Input Arguments

strings

string vector [nStrings]
The set of strings being checked

list

string vector
The set of allowed strings

name

string scalar
The name of strings in the calling function. Default is “strings”

listName

string scalar
The name of list in the calling function. Default is “value in the list”

idHeader

string scalar
A header for thrown error IDs. Default is “DASH:assert:strsInList”

Output Arguments

k

vector, linear indices [nStrings]
The index of each element of strings in the list of allowed values