---
schema_version: "1"
id: fea6ef4d71ffdcb14120210f3a298f8c6a51b0e582aa703e39d4ede653285a9e
title: failIf
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-runtime-functions-failif.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-runtime-functions-failif
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1da0502507974ccd36848fad85926ba709eaff2a240d22efda1a3340d5f5465e
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# failIf

## [](#failif1)failIf(T, (value: T) -> Boolean, String): T

エバリュエーターの式が ​`true`​ を返す場合は、指定されたメッセージでエラーを生成し、それ以外の場合は値を返します。

### [](#パラメーター)パラメーター

<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">名前</th>
<th class="tableblock halign-left valign-top">説明</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"><code>evaluator</code>​ 式が ​<code>false</code>​ の場合のみ返す値。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>evaluator</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code>​ または ​<code>false</code>​ を返す式。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、式 ​`isEmpty(result)`​ が ​`true`​ であるため、(SUCCESS メッセージの代わりに) ランタイムエラーを生成します。この式が ​`true`​ なのは、空のオブジェクトが変数 ​`result`​ に渡されているためです。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
import failIf from dw::Runtime
var result = {}
output application/json
---
{ "result" : failIf(result, isEmpty) }
```

#### [](#出力)出力

```TXT
ERROR 2018-07-29 11:56:39,988 ...
**********************************
Message               : "Failed
```

または、関数は値を出力します。

#### [](#ソース-2)ソース

```DataWeave
%dw 2.0
import failIf from dw::Runtime
var result = {"a":"test"}
output application/json
---
{ "result" : result failIf isEmpty($) }
```

#### [](#出力-2)出力

```Json
{
  "result": {
    "a": "test"
  }
}
```