Enum DataValidationCriteria
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
معیارهای اعتبارسنجی داده ها شمارشی که معیارهای اعتبارسنجی داده را نشان می دهد که می تواند روی یک محدوده تنظیم شود.
برای فراخوانی یک enum، کلاس والد، نام و ویژگی آن را فراخوانی می کنید. برای مثال، SpreadsheetApp.DataValidationCriteria.DATE_IS_VALID_DATE
.
// Change existing data-validation rules that require a date in 2013 to require
// a date in 2014.
const oldDates = [new Date('1/1/2013'), new Date('12/31/2013')];
const newDates = [new Date('1/1/2014'), new Date('12/31/2014')];
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());
const rules = range.getDataValidations();
for (let i = 0; i < rules.length; i++) {
for (let j = 0; j < rules[i].length; j++) {
const rule = rules[i][j];
if (rule != null) {
const criteria = rule.getCriteriaType();
const args = rule.getCriteriaValues();
if (criteria === SpreadsheetApp.DataValidationCriteria.DATE_BETWEEN &&
args[0].getTime() === oldDates[0].getTime() &&
args[1].getTime() === oldDates[1].getTime()) {
// Create a builder from the existing rule, then change the dates.
rules[i][j] = rule.copy().withCriteria(criteria, newDates).build();
}
}
}
}
range.setDataValidations(rules);
خواص
اموال | تایپ کنید | توضیحات |
---|
DATE_AFTER | Enum | به تاریخی نیاز دارد که بعد از مقدار داده شده باشد. |
DATE_BEFORE | Enum | به تاریخی نیاز دارد که قبل از مقدار داده شده باشد. |
DATE_BETWEEN | Enum | به تاریخی نیاز دارد که بین مقادیر داده شده باشد. |
DATE_EQUAL_TO | Enum | به تاریخی نیاز دارد که برابر با مقدار داده شده باشد. |
DATE_IS_VALID_DATE | Enum | نیاز به تاریخ دارد. |
DATE_NOT_BETWEEN | Enum | به تاریخی نیاز دارد که بین مقادیر داده شده نباشد. |
DATE_ON_OR_AFTER | Enum | به تاریخی نیاز دارید که در مقدار داده شده یا بعد از آن باشد. |
DATE_ON_OR_BEFORE | Enum | به تاریخی نیاز دارد که در یا قبل از مقدار داده شده باشد. |
NUMBER_BETWEEN | Enum | به عددی نیاز دارد که بین مقادیر داده شده باشد. |
NUMBER_EQUAL_TO | Enum | به عددی نیاز دارد که برابر با مقدار داده شده باشد. |
NUMBER_GREATER_THAN | Enum | به عددی نیاز دارید که بزرگتر از مقدار داده شده باشد. |
NUMBER_GREATER_THAN_OR_EQUAL_TO | Enum | به عددی نیاز دارد که بزرگتر یا مساوی با مقدار داده شده باشد. |
NUMBER_LESS_THAN | Enum | به عددی نیاز دارد که کمتر از مقدار داده شده باشد. |
NUMBER_LESS_THAN_OR_EQUAL_TO | Enum | به عددی نیاز دارد که کمتر یا مساوی با مقدار داده شده باشد. |
NUMBER_NOT_BETWEEN | Enum | به عددی نیاز دارد که بین مقادیر داده شده نباشد. |
NUMBER_NOT_EQUAL_TO | Enum | به عددی نیاز دارد که با مقدار داده شده برابر نباشد. |
TEXT_CONTAINS | Enum | مستلزم آن است که ورودی حاوی مقدار داده شده باشد. |
TEXT_DOES_NOT_CONTAIN | Enum | نیاز دارد که ورودی حاوی مقدار داده شده نباشد. |
TEXT_EQUAL_TO | Enum | مستلزم آن است که ورودی برابر با مقدار داده شده باشد. |
TEXT_IS_VALID_EMAIL | Enum | نیاز دارد که ورودی به شکل یک آدرس ایمیل باشد. |
TEXT_IS_VALID_URL | Enum | نیاز دارد که ورودی به شکل URL باشد. |
VALUE_IN_LIST | Enum | مستلزم آن است که ورودی برابر با یکی از مقادیر داده شده باشد. |
VALUE_IN_RANGE | Enum | مستلزم آن است که ورودی برابر با مقداری در محدوده داده شده باشد. |
CUSTOM_FORMULA | Enum | مستلزم آن است که ورودی فرمول داده شده را true ارزیابی کند. |
CHECKBOX | Enum | نیاز دارد که ورودی یک مقدار سفارشی یا یک بولی باشد. به عنوان یک چک باکس ارائه شده است. |
DATE_AFTER_RELATIVE | Enum | به تاریخی نیاز دارد که بعد از مقدار تاریخ نسبی باشد. |
DATE_BEFORE_RELATIVE | Enum | به تاریخی نیاز دارد که قبل از مقدار تاریخ نسبی باشد. |
DATE_EQUAL_TO_RELATIVE | Enum | به تاریخی نیاز دارد که برابر با مقدار تاریخ نسبی باشد. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-04 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-04 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eDataValidationCriteria\u003c/code\u003e is an enumeration used to define data validation rules for cell ranges in Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eIt provides various criteria like \u003ccode\u003eDATE_BETWEEN\u003c/code\u003e, \u003ccode\u003eNUMBER_GREATER_THAN\u003c/code\u003e, \u003ccode\u003eTEXT_CONTAINS\u003c/code\u003e, and more to enforce data integrity.\u003c/p\u003e\n"],["\u003cp\u003eTo use a specific criterion, you refer to it through \u003ccode\u003eSpreadsheetApp.DataValidationCriteria\u003c/code\u003e followed by the specific property, for instance, \u003ccode\u003eSpreadsheetApp.DataValidationCriteria.DATE_IS_VALID_DATE\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code example demonstrates how to modify existing data validation rules that require a date within a certain range.\u003c/p\u003e\n"]]],["`DataValidationCriteria` defines the types of data validation rules applicable to a spreadsheet range. You can retrieve or modify existing rules on a range, to change the validation criteria. For example, you can update all DATE_BETWEEN rules from a date range in 2013 to a new date range in 2014, by copying and modifying the existing rule, or set new validation criteria on a range to ensure certain data types, including dates, numbers, or text, fit within specified parameters.\n"],null,["# Enum DataValidationCriteria\n\nDataValidationCriteria\n\nAn enumeration representing the data validation criteria that can be set on a range.\n\nTo call an enum, you call its parent class, name, and property. For example, `\nSpreadsheetApp.DataValidationCriteria.DATE_IS_VALID_DATE`.\n\n```javascript\n// Change existing data-validation rules that require a date in 2013 to require\n// a date in 2014.\nconst oldDates = [new Date('1/1/2013'), new Date('12/31/2013')];\nconst newDates = [new Date('1/1/2014'), new Date('12/31/2014')];\nconst sheet = SpreadsheetApp.getActiveSheet();\nconst range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());\nconst rules = range.getDataValidations();\n\nfor (let i = 0; i \u003c rules.length; i++) {\n for (let j = 0; j \u003c rules[i].length; j++) {\n const rule = rules[i][j];\n\n if (rule != null) {\n const criteria = rule.getCriteriaType();\n const args = rule.getCriteriaValues();\n\n if (criteria === SpreadsheetApp.DataValidationCriteria.DATE_BETWEEN &&\n args[0].getTime() === oldDates[0].getTime() &&\n args[1].getTime() === oldDates[1].getTime()) {\n // Create a builder from the existing rule, then change the dates.\n rules[i][j] = rule.copy().withCriteria(criteria, newDates).build();\n }\n }\n }\n}\nrange.setDataValidations(rules);\n``` \n\n### Properties\n\n| Property | Type | Description |\n|-----------------------------------|--------|---------------------------------------------------------------------------------|\n| `DATE_AFTER` | `Enum` | Requires a date that is after the given value. |\n| `DATE_BEFORE` | `Enum` | Requires a date that is before the given value. |\n| `DATE_BETWEEN` | `Enum` | Requires a date that is between the given values. |\n| `DATE_EQUAL_TO` | `Enum` | Requires a date that is equal to the given value. |\n| `DATE_IS_VALID_DATE` | `Enum` | Requires a date. |\n| `DATE_NOT_BETWEEN` | `Enum` | Requires a date that is not between the given values. |\n| `DATE_ON_OR_AFTER` | `Enum` | Require a date that is on or after the given value. |\n| `DATE_ON_OR_BEFORE` | `Enum` | Requires a date that is on or before the given value. |\n| `NUMBER_BETWEEN` | `Enum` | Requires a number that is between the given values. |\n| `NUMBER_EQUAL_TO` | `Enum` | Requires a number that is equal to the given value. |\n| `NUMBER_GREATER_THAN` | `Enum` | Require a number that is greater than the given value. |\n| `NUMBER_GREATER_THAN_OR_EQUAL_TO` | `Enum` | Requires a number that is greater than or equal to the given value. |\n| `NUMBER_LESS_THAN` | `Enum` | Requires a number that is less than the given value. |\n| `NUMBER_LESS_THAN_OR_EQUAL_TO` | `Enum` | Requires a number that is less than or equal to the given value. |\n| `NUMBER_NOT_BETWEEN` | `Enum` | Requires a number that is not between the given values. |\n| `NUMBER_NOT_EQUAL_TO` | `Enum` | Requires a number that is not equal to the given value. |\n| `TEXT_CONTAINS` | `Enum` | Requires that the input contains the given value. |\n| `TEXT_DOES_NOT_CONTAIN` | `Enum` | Requires that the input does not contain the given value. |\n| `TEXT_EQUAL_TO` | `Enum` | Requires that the input is equal to the given value. |\n| `TEXT_IS_VALID_EMAIL` | `Enum` | Requires that the input is in the form of an email address. |\n| `TEXT_IS_VALID_URL` | `Enum` | Requires that the input is in the form of a URL. |\n| `VALUE_IN_LIST` | `Enum` | Requires that the input is equal to one of the given values. |\n| `VALUE_IN_RANGE` | `Enum` | Requires that the input is equal to a value in the given range. |\n| `CUSTOM_FORMULA` | `Enum` | Requires that the input makes the given formula evaluate to `true`. |\n| `CHECKBOX` | `Enum` | Requires that the input is a custom value or a boolean; rendered as a checkbox. |\n| `DATE_AFTER_RELATIVE` | `Enum` | Requires a date that is after the relative date value. |\n| `DATE_BEFORE_RELATIVE` | `Enum` | Requires a date that is before the relative date value. |\n| `DATE_EQUAL_TO_RELATIVE` | `Enum` | Requires a date that is equal to the relative date value. |"]]