Skip to content

Commit 612355b

Browse files
🤖 Merge PR DefinitelyTyped#73735 google-apps-script: Added Validation for TextInput by @YamanquiChacala
Co-authored-by: Yamanqui García Rosales <yamanqui@gmail.com>
1 parent e9f232d commit 612355b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎types/google-apps-script/google-apps-script.card-service.d.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ declare namespace GoogleAppsScript {
270270
SwitchControlType: typeof SwitchControlType;
271271
TextButtonStyle: typeof TextButtonStyle;
272272
UpdateDraftBodyType: typeof UpdateDraftBodyType;
273+
InputType: typeof InputType;
273274
newAction(): Action;
274275
newActionResponseBuilder(): ActionResponseBuilder;
275276
newAttachment(): Attachment;
@@ -336,6 +337,7 @@ declare namespace GoogleAppsScript {
336337
newUpdateDraftCcRecipientsAction(): UpdateDraftCcRecipientsAction;
337338
newUpdateDraftSubjectAction(): UpdateDraftSubjectAction;
338339
newUpdateDraftToRecipientsAction(): UpdateDraftToRecipientsAction;
340+
newValidation(): Validation;
339341
}
340342
/**
341343
* The response object that may be returned from a callback method for compose action in a Gmail add-on.
@@ -839,6 +841,7 @@ declare namespace GoogleAppsScript {
839841
setSuggestions(suggestions: Suggestions): TextInput;
840842
setSuggestionsAction(suggestionsAction: Action): TextInput;
841843
setTitle(title: string): TextInput;
844+
setValidation(validation: Validation): TextInput;
842845
setValue(value: string): TextInput;
843846
}
844847
/**
@@ -993,6 +996,29 @@ declare namespace GoogleAppsScript {
993996
interface UpdateDraftToRecipientsAction {
994997
addUpdateToRecipients(toRecipientEmails: string[]): UpdateDraftToRecipientsAction;
995998
}
999+
1000+
/**
1001+
* An object that defines the validation rule for the widget that it is attached to.
1002+
*
1003+
* const validation = CardService.newValidation()
1004+
* .setCharacterLimit('10')
1005+
* .setInputType(CardService.InputType.TEXT);
1006+
*/
1007+
interface Validation {
1008+
setCharacterLimit(characterLimit: Integer): Validation;
1009+
setInputType(inputType: InputType): Validation;
1010+
}
1011+
1012+
/**
1013+
* An enum that defines the input type of the widget.
1014+
*/
1015+
enum InputType {
1016+
TEXT,
1017+
INTEGER,
1018+
FLOAT,
1019+
EMAIL,
1020+
}
1021+
9961022
/**
9971023
* The fixed footer shown at the bottom of an add-on Card.
9981024
*/

‎types/google-apps-script/test/google-apps-script-tests.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ CardService.newMaterialIcon().setGrade(100); // $ExpectType MaterialIcon
627627
CardService.newMaterialIcon().setName(""); // $ExpectType MaterialIcon
628628
CardService.newMaterialIcon().setWeight(100); // $ExpectType MaterialIcon
629629

630+
CardService.newValidation(); // $ExpectType Validation
631+
CardService.newValidation().setCharacterLimit(10) // $ExpectType Validation
632+
CardService.newValidation().setInputType(CardService.InputType.TEXT) // $ExpectType Validation
633+
630634
// CardService.newCardBuilder().setDisplayStyle(CardService.DisplayStyle.PEEK)
631635
CardService.DisplayStyle.PEEK;
632636
CardService.DisplayStyle.REPLACE;

0 commit comments

Comments
 (0)