AI-generated Key Takeaways
-
Validation objects define rules for widgets, such as character limits and input types, ensuring data integrity.
-
They are available for Google Chat apps and Workspace Add-ons, offering developers control over user input.
-
Developers can leverage methods like
setCharacterLimit
andsetInputType
to customize validation behavior. -
The
setCharacterLimit
method specifically applies toTextInput
widgets, enforcing maximum character input. -
Similarly,
setInputType
dictates the accepted input type, enhancing user experience and data accuracy.
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').setInputType( CardService.InputType.TEXT);
Methods
Method | Return type | Brief description |
---|---|---|
set | Validation | Sets the character limit of the widget. |
set | 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 |
---|---|---|
character | Integer | The character limit to set. Note that this restriction is only effective
for Text 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
Name | Type | Description |
---|---|---|
input | Input | The Input to set. |
Return
Validation
— This object, for chaining.