The every()
function will return true if all items in a list match the condition (unlike some, which only requires at least one element to match it).
every(list, condition)
list.every(condition)
Code language: JavaScript (javascript)
Example formulas
[1, 2, 3, 4, 5].every(
current > 0
)
/* Output: true */
Code language: JavaScript (javascript)
You can use every()
to validate dates. Note how the last date in this example list is invalid:
["1999-04-01", "2023-01-25", "2025-13-32"].every(
current.parseDate()
)
/* Output: false */
Code language: JavaScript (javascript)
You can also use every()
to run a check on a specific property within every page in a Relation property. For example, let’s say we want to check whether or not every task in a project is done:
prop("Tasks").every(
current.prop("Status") == "Done"
)
/* Sample Output: false */
Code language: JavaScript (javascript)
Once you have this value in a formula property, you could even filter a database view by it in order to show only projects that have incomplete tasks.