Class Validation

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.

const validation = CardService.newValidation()
    .setCharacterLimit('10')
    .setType(CardService.InputType.TEXT)
    .setWeight(400)
    .setGrade(0);

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 for TextInput 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
inputTypeInputTypeThe InputType to set.

Return

Validation — This object, for chaining.