From 612355bb6bce56c81a369022c2f7eab9c0ef7ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yamanqui=20Garc=C3=ADa=20Rosales?= Date: Tue, 23 Sep 2025 23:45:50 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#73735=20google?= =?UTF-8?q?-apps-script:=20Added=20Validation=20for=20TextInput=20by=20@Ya?= =?UTF-8?q?manquiChacala?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yamanqui GarcĂ­a Rosales --- .../google-apps-script.card-service.d.ts | 26 +++++++++++++++++++ .../test/google-apps-script-tests.ts | 4 +++ 2 files changed, 30 insertions(+) diff --git a/types/google-apps-script/google-apps-script.card-service.d.ts b/types/google-apps-script/google-apps-script.card-service.d.ts index b387e51390e15f..69bde44953857d 100644 --- a/types/google-apps-script/google-apps-script.card-service.d.ts +++ b/types/google-apps-script/google-apps-script.card-service.d.ts @@ -270,6 +270,7 @@ declare namespace GoogleAppsScript { SwitchControlType: typeof SwitchControlType; TextButtonStyle: typeof TextButtonStyle; UpdateDraftBodyType: typeof UpdateDraftBodyType; + InputType: typeof InputType; newAction(): Action; newActionResponseBuilder(): ActionResponseBuilder; newAttachment(): Attachment; @@ -336,6 +337,7 @@ declare namespace GoogleAppsScript { newUpdateDraftCcRecipientsAction(): UpdateDraftCcRecipientsAction; newUpdateDraftSubjectAction(): UpdateDraftSubjectAction; newUpdateDraftToRecipientsAction(): UpdateDraftToRecipientsAction; + newValidation(): Validation; } /** * 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 { setSuggestions(suggestions: Suggestions): TextInput; setSuggestionsAction(suggestionsAction: Action): TextInput; setTitle(title: string): TextInput; + setValidation(validation: Validation): TextInput; setValue(value: string): TextInput; } /** @@ -993,6 +996,29 @@ declare namespace GoogleAppsScript { interface UpdateDraftToRecipientsAction { addUpdateToRecipients(toRecipientEmails: string[]): UpdateDraftToRecipientsAction; } + + /** + * An object that defines the validation rule for the widget that it is attached to. + * + * const validation = CardService.newValidation() + * .setCharacterLimit('10') + * .setInputType(CardService.InputType.TEXT); + */ + interface Validation { + setCharacterLimit(characterLimit: Integer): Validation; + setInputType(inputType: InputType): Validation; + } + + /** + * An enum that defines the input type of the widget. + */ + enum InputType { + TEXT, + INTEGER, + FLOAT, + EMAIL, + } + /** * The fixed footer shown at the bottom of an add-on Card. */ diff --git a/types/google-apps-script/test/google-apps-script-tests.ts b/types/google-apps-script/test/google-apps-script-tests.ts index ace09b17bd0f95..d81ada15fdb365 100644 --- a/types/google-apps-script/test/google-apps-script-tests.ts +++ b/types/google-apps-script/test/google-apps-script-tests.ts @@ -627,6 +627,10 @@ CardService.newMaterialIcon().setGrade(100); // $ExpectType MaterialIcon CardService.newMaterialIcon().setName(""); // $ExpectType MaterialIcon CardService.newMaterialIcon().setWeight(100); // $ExpectType MaterialIcon +CardService.newValidation(); // $ExpectType Validation +CardService.newValidation().setCharacterLimit(10) // $ExpectType Validation +CardService.newValidation().setInputType(CardService.InputType.TEXT) // $ExpectType Validation + // CardService.newCardBuilder().setDisplayStyle(CardService.DisplayStyle.PEEK) CardService.DisplayStyle.PEEK; CardService.DisplayStyle.REPLACE; From 1749ccf640b07519fd69a72c2a5bcc0fc050c056 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 24 Sep 2025 06:46:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20dprint=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/google-apps-script/google-apps-script.card-service.d.ts | 2 +- types/google-apps-script/test/google-apps-script-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/google-apps-script/google-apps-script.card-service.d.ts b/types/google-apps-script/google-apps-script.card-service.d.ts index 69bde44953857d..1f5c1eb0c2056c 100644 --- a/types/google-apps-script/google-apps-script.card-service.d.ts +++ b/types/google-apps-script/google-apps-script.card-service.d.ts @@ -999,7 +999,7 @@ declare namespace GoogleAppsScript { /** * An object that defines the validation rule for the widget that it is attached to. - * + * * const validation = CardService.newValidation() * .setCharacterLimit('10') * .setInputType(CardService.InputType.TEXT); diff --git a/types/google-apps-script/test/google-apps-script-tests.ts b/types/google-apps-script/test/google-apps-script-tests.ts index d81ada15fdb365..c71ed8e55fc6d9 100644 --- a/types/google-apps-script/test/google-apps-script-tests.ts +++ b/types/google-apps-script/test/google-apps-script-tests.ts @@ -628,8 +628,8 @@ CardService.newMaterialIcon().setName(""); // $ExpectType MaterialIcon CardService.newMaterialIcon().setWeight(100); // $ExpectType MaterialIcon CardService.newValidation(); // $ExpectType Validation -CardService.newValidation().setCharacterLimit(10) // $ExpectType Validation -CardService.newValidation().setInputType(CardService.InputType.TEXT) // $ExpectType Validation +CardService.newValidation().setCharacterLimit(10); // $ExpectType Validation +CardService.newValidation().setInputType(CardService.InputType.TEXT); // $ExpectType Validation // CardService.newCardBuilder().setDisplayStyle(CardService.DisplayStyle.PEEK) CardService.DisplayStyle.PEEK;