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

## [](#failif1)failIf<T>(value: T, evaluator: (value: T) -> Boolean, message: String = 'Failed'): 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"
  }
}
```