---
schema_version: "1"
id: 4eea971f21864d8189e1859ea985757e8bef52a528f9ba5488a6f707e4b8d1d3
title: nodeExists
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-tree-functions-nodeexists.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-tree-functions-nodeexists
source_site: docs.mulesoft.com
content_type: documentation
content_hash: dadb6168a56e590c1a40aaaf22eabe22bfd745535c64da62068e850e7dc1a788
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

# nodeExists

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## nodeExists(value: Any, callback: (value: Any, path: Path) -> Boolean): Boolean

Returns `true` if any node in a given tree validates against the specified criteria.

_Introduced in DataWeave version 2.2.2._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>value</code></p></td><td><p>The value to search.</p></td></tr><tr><td><p><code>callback</code></p></td><td><p>The criteria to apply to the input <code>value</code>.</p></td></tr></tbody></table>

### Example

This example checks for each user by name and last name. Notice that you can also reference a
`value` with `$` and the `path` with `$$`.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Tree
var myObject =  {
     user: [{
         name: "mariano",
         lastName: "achaval",
         friends: [
             {
                 name: "julian"
             },
             {
                 name: "tom"
             }
         ]
     },
     {
         name: "leandro",
         lastName: "shokida",
         friends: [
             {
                 name: "peter"
             },
             {
                 name: "robert"
             }
         ]

     }
     ]
 }
output application/json
---
{
    mariano : myObject nodeExists ((value, path) -> path[-1].selector == "name" and value == "mariano"),
    julian : myObject nodeExists ((value, path) -> path[-1].selector == "name" and value == "julian"),
    tom : myObject nodeExists ($$[-1].selector == "name" and $ == "tom"),
    leandro : myObject nodeExists ($$[-1].selector == "name" and $ ==  "leandro"),
    peter : myObject nodeExists ($$[-1].selector == "name" and $ == "peter"),
    wrongField: myObject nodeExists ($$[-1].selector == "wrongField"),
    teo: myObject nodeExists ($$[-1].selector == "name" and $ == "teo")
}
```

#### Output

```Json
{
  "mariano": true,
  "julian": true,
  "tom": true,
  "leandro": true,
  "peter": true,
  "wrongField": false,
  "teo": false
}
```
