Contact Us 1-800-596-4880

someEntry

someEntry(Object, (value: Any, key: Key) -> Boolean): Boolean

Returns true if at least one entry in the object matches the specified condition.

The function stops iterating after the first element that matches the condition is found.

Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.

Parameters

Name Description

obj

The object to evaluate.

condition

The condition to use when evaluating elements in the object.

Example

This example shows how the someEntry behaves with different inputs.

Source

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

Output

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

someEntry(Null, (value: Nothing, key: Nothing) -> Boolean): Boolean

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

Introduced in DataWeave 2.3.0. Supported by Mule 4.3 and later.