Skip to main content

CONTAINS_ONLY

Written by Arnaud Lachaume
Updated today

Type: Function

Function: CONTAINS_ONLY

Syntax: CONTAINS_ONLY(list, term|term_list)

Description: Returns true if every element in the list matches at least one of the provided values. Unlike CONTAINS_EXACTLY, it does not require all provided values to be present - it only checks that no unexpected values exist.

By strict definition, an empty list will return true.

Sample usage:

  • CONTAINS_ONLY(label_names, "bug") returns true if label_names contains nothing but bug entries.

  • CONTAINS_ONLY(label_names, ["bug", "enhancement"]) returns true if every label is either bug or enhancement. The list does not need to contain both.

  • CONTAINS_ONLY(assignee_usernames, ["john", "jenny"]) returns true if every assignee is john or jenny, otherwise it returns false.

  • CONTAINS_ONLY(["bug", "bug"], ["bug", "enhancement"]) returns true because every element in the first array is found in the second one.

  • CONTAINS_ONLY(["bug", "enhancement", "security"], ["bug", "enhancement"]) returns false because security is not in the allowed values.

  • CONTAINS_ONLY([], ["bug", "enhancement"]) returns true because the tested array has no elements.

Did this answer your question?