Contact Us 1-800-596-4880

everyEntry

everyEntry(object: Object, condition: (value: Any, key: Key) -> Boolean): Boolean

Returns true if every entry in the object matches the condition.

The function stops iterating after the first negative evaluation of an element in the object.

Introduced in DataWeave version 2.3.0.

Parameters

Name Description

object

The object to evaluate.

condition

The condition to apply to each element.

Example

This example shows how everyEntry behaves with different inputs.

Source

%dw 2.0
import everyEntry from dw::core::Objects
output application/json
---
{
    a: {} everyEntry (value, key) -> value is String,
    b: {a: "", b: "123"} everyEntry (value, key) -> value is String,
    c: {a: "", b: 123} everyEntry (value, key) -> value is String,
    d: {a: "", b: 123} everyEntry (value, key) -> key as String == "a",
    e: {a: ""} everyEntry (value, key) -> key as String == "a",
    f: null everyEntry ((value, key) -> key as String == "a")
}

Output

{
  "a": true,
  "b": true,
  "c": false,
  "d": false,
  "e": true,
  "f": true
}

everyEntry(list: Null, condition: (Nothing, Nothing) -> Boolean): Boolean

Helper function that enables everyEntry to work with a null value.

Introduced in DataWeave version 2.3.0.