---
schema_version: "1"
id: 16e7ebed8dbffb2643539ceb25fd5a91c6611e767ef87c41e8e62971ca135040
title: mask
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-values-functions-mask.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-values-functions-mask
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 315ca4cc0aedb61a37f2cf8bd67bd0ca83ae0d2d2ea3630ddd3c330e259eacf2
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
# mask

## [](#mask1)mask(value: Null, fieldName: String | Number | PathElement): (newValueProvider: (oldValue: Any, path: Path) -> Any) -> Null

Helper function that enables `mask` to work with a `null` value.

_Introduced in DataWeave version 2.2.2._

## [](#mask2)mask(value: Any, selector: PathElement): (newValueProvider: (oldValue: Any, path: Path) -> Any) -> Any

This `mask` function replaces all _simple_ elements that match the specified criteria.

Simple elements do not have child elements and cannot be objects or arrays.

_Introduced in DataWeave version 2.2.2._

### [](#parameters)Parameters

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>value</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A value to use for masking. The value can be any DataWeave type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>selector</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The <code>PathElement</code> selector.</p></td>
</tr>
</tbody>
</table>

### [](#example)Example

This example shows how to mask the value of a `password` field in an array of objects. It uses `field("password")` to return the `PathElement` that it passes to `mask`. It uses `with "**"**` **to specify the value (**) to use for masking.

#### [](#source)Source

```DataWeave
%dw 2.0
output application/json
import * from dw::util::Values
---
[{name: "Peter Parker", password: "spiderman"}, {name: "Bruce Wayne", password: "batman"}] mask field("password") with "*****"
```

#### [](#output)Output

```Json
[
   {
     "name": "Peter Parker",
     "password": "*****"
   },
   {
     "name": "Bruce Wayne",
     "password": "*****"
   }
 ]
```

## [](#mask3)mask(value: Any, fieldName: String): (newValueProvider: (oldValue: Any, path: Path) -> Any) -> Any

This `mask` function selects a field by its name.

_Introduced in DataWeave version 2.2.2._

### [](#parameters-2)Parameters

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>value</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The value to use for masking. The value can be any DataWeave type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>fieldName</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A string that specifies the name of the field to mask.</p></td>
</tr>
</tbody>
</table>

### [](#example-2)Example

This example shows how to perform masking using the name of a field in the input. It modifies the values of all fields with that value.

#### [](#source-2)Source

```DataWeave
%dw 2.0
output application/json
import * from dw::util::Values
---
[{name: "Peter Parker", password: "spiderman"}, {name: "Bruce Wayne", password: "batman"}] mask "password" with "*****"
```

#### [](#output-2)Output

```Json
[
   {
     "name": "Peter Parker",
     "password": "*****"
   },
   {
     "name": "Bruce Wayne",
     "password": "*****"
   }
 ]
```

## [](#mask4)mask(value: Any, i: Number): (newValueProvider: (oldValue: Any, path: Path) -> Any) -> Any

This `mask` function selects an element from array by its index.

_Introduced in DataWeave version 2.2.2._

### [](#parameters-3)Parameters

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Name</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>value</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The value to mask. The value can be any DataWeave type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>index</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The index to mask. The index must be a number.</p></td>
</tr>
</tbody>
</table>

### [](#example-3)Example

This example shows how `mask` acts on all elements in the nested arrays. It changes the value of each element at index `1` to `false`.

#### [](#source-3)Source

```DataWeave
%dw 2.0
output application/json
import * from dw::util::Values
---
[[123, true], [456, true]] mask 1 with false
```

#### [](#output-3)Output

```Json
[
   [
     123,
     false
   ],
   [
     456,
     false
   ]
 ]
```