Class Validation
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Xác nhận kết quả
Một đối tượng xác định quy tắc xác thực cho tiện ích mà đối tượng đó được đính kèm.
Có sẵn cho các ứng dụng Google Chat và tiện ích bổ sung của Google Workspace.
const validation = CardService.newValidation().setCharacterLimit('10').setInputType(
CardService.InputType.TEXT);
Tài liệu chi tiết
setCharacterLimit(characterLimit)
Đặt giới hạn ký tự của tiện ích.
Có sẵn cho các ứng dụng Google Chat và tiện ích bổ sung của Google Workspace.
Thông số
Tên | Loại | Mô tả |
characterLimit | Integer | Giới hạn ký tự cần đặt. Xin lưu ý rằng quy định hạn chế này chỉ có hiệu lực đối với TextInput và bị bỏ qua đối với các tiện ích khác. |
Cầu thủ trả bóng
Validation
– Đối tượng này, để tạo chuỗi.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eValidation objects define rules for widgets, such as character limits and input types, ensuring data integrity.\u003c/p\u003e\n"],["\u003cp\u003eThey are available for Google Chat apps and Workspace Add-ons, offering developers control over user input.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage methods like \u003ccode\u003esetCharacterLimit\u003c/code\u003e and \u003ccode\u003esetInputType\u003c/code\u003e to customize validation behavior.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetCharacterLimit\u003c/code\u003e method specifically applies to \u003ccode\u003eTextInput\u003c/code\u003e widgets, enforcing maximum character input.\u003c/p\u003e\n"],["\u003cp\u003eSimilarly, \u003ccode\u003esetInputType\u003c/code\u003e dictates the accepted input type, enhancing user experience and data accuracy.\u003c/p\u003e\n"]]],[],null,["# Class Validation\n\nValidation\n\nAn object that defines the validation rule for the widget that it is attached to.\n\nAvailable for Google Chat apps and Google Workspace add-ons.\n\n```javascript\nconst validation = CardService.newValidation().setCharacterLimit('10').setInputType(\n CardService.InputType.TEXT);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------|-----------------|-----------------------------------------|\n| [setCharacterLimit(characterLimit)](#setCharacterLimit(Integer)) | [Validation](#) | Sets the character limit of the widget. |\n| [setInputType(inputType)](#setInputType(InputType)) | [Validation](#) | Sets the input type of the widget. |\n\nDetailed documentation\n----------------------\n\n### `set``Character``Limit(characterLimit)`\n\nSets the character limit of the widget.\n\nAvailable for Google Chat apps and Google Workspace add-ons.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `character``Limit` | `Integer` | The character limit to set. Note that this restriction is only effective for [TextInput](/apps-script/reference/card-service/text-input) and is ignored for other widgets. |\n\n#### Return\n\n\n[Validation](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Input``Type(inputType)`\n\nSets the input type of the widget.\n\nAvailable for Google Chat apps and Google Workspace add-ons.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|-------------------------------------------------------------|-------------------------------------------------------------------------|\n| `input``Type` | [InputType](/apps-script/reference/card-service/input-type) | The [InputType](/apps-script/reference/card-service/input-type) to set. |\n\n#### Return\n\n\n[Validation](#) --- This object, for chaining."]]