Class Validation

  • A Validation object defines the validation rule for an attached widget.

  • Validation is available for Google Chat apps and Google Workspace add-ons.

  • ThesetCharacterLimit method sets the maximum number of characters allowed in a widget.

  • ThesetInputType method sets the type of input expected for a widget.

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.

constvalidation=CardService.newValidation().setCharacterLimit('10').setInputType(CardService.InputType.TEXT);

Methods

MethodReturn typeBrief description
setCharacterLimit(characterLimit)ValidationSets the character limit of the widget.
setInputType(inputType)ValidationSets 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

NameTypeDescription
characterLimitIntegerThe character limit to set. Note that this restriction is only effective forTextInput and is ignored for other widgets.

Return

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

NameTypeDescription
inputTypeInputTypeTheInputType to set.

Return

Validation — This object, for chaining.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-03 UTC.