---
schema_version: "1"
id: 348732c1677c13bcf3a78e7dd1b37e4acb7e1bc7511a4da690e9c5dd51cd8fb1
title: withMaxSize
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-strings-functions-withmaxsize.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-strings-functions-withmaxsize
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9dea0c79015f48241790dac10236b17650bbfb7c249b85a1af53d48ae4115c88
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# withMaxSize

## [](#withmaxsize1)withMaxSize(text: String, maxLength: Number): String

文字列長が指定された ​`maxLength`​ より長くないことを確認します。 文字列の長さが ​`maxLength`​ よりも長い場合、関数では文字列長が長さ制限を満たすまで、文字が左から右に切り捨てられます。

_DataWeave バージョン 2.3.0 で導入されました。_

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

<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>text</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">入力文字列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>maxLength</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">文字列の最大長さ。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、同じ文字列の異なる ​`maxLength`​ での ​`withMaxSize`​ の動作を示します。 `withMaxSize`​ が 0 の場合、関数は未変更の文字列を返します。入力が ​`null`​ であれば、出力は常に ​`null`​ になります。

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

```DataWeave
%dw 2.0
import withMaxSize from dw::core::Strings
output application/json
---
{
   a: "123" withMaxSize 10,
   b: "123" withMaxSize 3,
   c: "123" withMaxSize 2,
   d: "123" withMaxSize 0,
   e: null withMaxSize 23,
}
```

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

```JSON
{
  "a": "123",
  "b": "123",
  "c": "12",
  "d": "123",
  "e": null
}
```

## [](#withmaxsize2)withMaxSize(text: Null, maxLength: Number): Null

`withMaxSize`​ を ​`null`​ 値に使用できるようにするヘルパー関数。

_DataWeave バージョン 2.3.0 で導入されました。_