Validation

An object that defines the validation rule for the widget that it is attached to.

Available for Google Chat apps and Google Workspace add-ons.

```javascript
const validation = CardService.newValidation().setCharacterLimit('10').setInputType(
    CardService.InputType.TEXT);
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/card-service/validation#setCharacterLimit(Integer)` | `https://developers.google.com/apps-script/reference/card-service/validation#` | Sets the character limit of the widget. |
| `https://developers.google.com/apps-script/reference/card-service/validation#setInputType(InputType)` | `https://developers.google.com/apps-script/reference/card-service/validation#` | Sets the input type of the widget. |

## Detailed documentation

### `setCharacterLimit(characterLimit)`

Sets the character limit of the widget.

Available for Google Chat apps and Google Workspace add-ons.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `characterLimit` | `Integer` | The character limit to set. Note that this restriction is only effective for `https://developers.google.com/apps-script/reference/card-service/text-input` and is ignored for other widgets. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/validation#` --- This object, for chaining.

*** ** * ** ***

### `setInputType(inputType)`

Sets the input type of the widget.

Available for Google Chat apps and Google Workspace add-ons.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `inputType` | `https://developers.google.com/apps-script/reference/card-service/input-type` | The `https://developers.google.com/apps-script/reference/card-service/input-type` to set. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/validation#` --- This object, for chaining.