데이터 검증 규칙 빌더입니다.
// Set the data validation for cell A1 to require a value from B1:B10. const cell = SpreadsheetApp.getActive().getRange('A1'); const range = SpreadsheetApp.getActive().getRange('B1:B10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build(); cell.setDataValidation(rule);
메서드
| 메서드 | 반환 유형 | 간략한 설명 |
|---|---|---|
build() | Data | 빌더에 적용된 설정에서 데이터 유효성 검사 규칙을 구성합니다. |
copy() | Data | 이 규칙의 설정을 기반으로 데이터 유효성 검사 규칙의 빌더를 만듭니다. |
get | Boolean | 입력 데이터 유효성 검사에 실패하면 규칙에서 경고를 표시하는 경우 true를 반환하고 입력을 완전히 거부하는 경우 false를 반환합니다. |
get | Data | Data enum에 정의된 대로 규칙의 기준 유형을 가져옵니다. |
get | Object[] | 규칙의 기준에 관한 인수 배열을 가져옵니다. |
get | String | 규칙의 도움말 텍스트를 가져오거나 도움말 텍스트가 설정되지 않은 경우 null를 가져옵니다. |
require | Data | 입력이 불리언 값이어야 하는 데이터 유효성 검사 규칙을 설정합니다. 이 값은 체크박스로 렌더링됩니다. |
require | Data | 입력 값이 지정된 값이거나 비워야 하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력이 지정된 값 중 하나여야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값 이후의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값보다 이전 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 두 날짜 사이의 날짜 또는 두 날짜 중 하나를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값과 동일한 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 두 날짜 사이 또는 지정된 두 날짜가 아닌 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값 이후의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값 이전의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 수식이 true으로 평가되도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 두 숫자 사이의 숫자 또는 지정된 두 숫자 중 하나를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값과 동일한 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값보다 큰 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값보다 크거나 같은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값보다 작은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값보다 작거나 같은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 두 숫자 사이 또는 지정된 두 숫자가 아닌 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 지정된 값과 같지 않은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력에 지정된 값이 포함되어야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력에 지정된 값이 포함되지 않아야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력이 지정된 값과 같아야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력값이 이메일 주소 형식이어야 하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력이 URL 형식이어야 하도록 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력이 지정된 값 중 하나와 같아야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력이 주어진 값 중 하나와 같아야 하는 데이터 유효성 검사 규칙을 설정하고 드롭다운 메뉴를 숨기는 옵션을 제공합니다. |
require | Data | 입력이 지정된 범위의 값과 같아야 하는 데이터 유효성 검사 규칙을 설정합니다. |
require | Data | 입력값이 지정된 범위의 값과 같아야 하는 데이터 유효성 검사 규칙을 설정하고 드롭다운 메뉴를 숨기는 옵션을 제공합니다. |
set | Data | 입력 데이터 유효성 검사에 실패할 때 경고를 표시할지 또는 입력을 완전히 거부할지 설정합니다. |
set | Data | 사용자가 데이터 유효성 검사가 설정된 셀 위로 마우스를 가져갈 때 표시되는 도움말 텍스트를 설정합니다. |
with | Data | 데이터 유효성 검사 규칙을 Data 값으로 정의된 기준으로 설정합니다. 일반적으로 기존 규칙의 criteria 및 arguments에서 가져옵니다. |
자세한 문서
build()
copy()
이 규칙의 설정을 기반으로 데이터 유효성 검사 규칙의 빌더를 만듭니다.
// 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);
리턴
Data: 이 규칙의 설정을 기반으로 하는 빌더
get Allow Invalid()
입력 데이터 유효성 검사에 실패하면 규칙에서 경고를 표시하는 경우 true를 반환하고 입력을 완전히 거부하는 경우 false를 반환합니다. 새 데이터 확인 규칙의 기본값은 true입니다.
리턴
Boolean: 규칙에서 데이터 유효성 검사에 실패하는 입력을 허용하는 경우 true, 허용하지 않는 경우 false입니다.
get Criteria Type()
Data enum에 정의된 대로 규칙의 기준 유형을 가져옵니다. 기준의 인수를 가져오려면 get를 사용합니다. 이러한 값을 사용하여 데이터 유효성 검사 규칙을 만들거나 수정하려면 with를 참고하세요.
// Log information about the data validation rule for cell A1. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = cell.getDataValidation(); if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); Logger.log('The data validation rule is %s %s', criteria, args); } else { Logger.log('The cell does not have a data validation rule.'); }
리턴
Data: 데이터 유효성 검사 기준 유형
get Criteria Values()
규칙의 기준에 관한 인수 배열을 가져옵니다. 기준 유형을 가져오려면 get를 사용합니다. 이러한 값을 사용하여 데이터 유효성 검사 규칙을 만들거나 수정하려면 with를 참고하세요.
// Log information about the data validation rule for cell A1. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = cell.getDataValidation(); if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); Logger.log('The data validation rule is %s %s', criteria, args); } else { Logger.log('The cell does not have a data validation rule.'); }
리턴
Object[]: 규칙의 기준 유형에 적합한 인수 배열입니다. 인수의 개수와 유형은 Data 클래스의 상응하는 require...() 메서드와 일치합니다.
get Help Text()
규칙의 도움말 텍스트를 가져오거나 도움말 텍스트가 설정되지 않은 경우 null를 가져옵니다.
리턴
String: 규칙의 도움말 텍스트 또는 도움말 텍스트가 설정되지 않은 경우 null
require Checkbox()
입력이 불리언 값이어야 하는 데이터 유효성 검사 규칙을 설정합니다. 이 값은 체크박스로 렌더링됩니다.
// Set the data validation for cell A1 to require a boolean value; the value is // rendered as a checkbox. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireCheckbox().build(); cell.setDataValidation(rule);
리턴
Data: 체이닝을 위한 이 빌더
require Checkbox(checkedValue)
입력 값이 지정된 값이거나 비워야 하도록 데이터 유효성 검사 규칙을 설정합니다. 입력이 지정된 값과 일치하면 셀이 선택된 체크박스로 렌더링됩니다. 입력이 비어 있으면 셀이 선택 해제된 체크박스로 렌더링됩니다.
// Set the data validation for cell A1 to require a custom checked value that is // rendered as a checkbox. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireCheckbox('APPROVED').build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
checked | Object | 선택된 체크박스에 할당된 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Checkbox(checkedValue, uncheckedValue)
입력이 지정된 값 중 하나여야 하는 데이터 유효성 검사 규칙을 설정합니다. 입력이 checked이면 셀이 선택된 체크박스로 렌더링됩니다. 입력이 unchecked이면 셀이 선택 해제된 체크박스로 렌더링됩니다.
// Set the data validation for cell A1 to require custom checked values that are // rendered as a checkbox. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireCheckbox('APPROVED', 'PENDING') .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
checked | Object | 선택된 체크박스에 할당된 값입니다. |
unchecked | Object | 선택되지 않은 체크박스에 할당된 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date()
날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a date. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireDate().build(); cell.setDataValidation(rule);
리턴
Data: 체이닝을 위한 이 빌더
require Date After(date)
지정된 값 이후의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date after January 1, 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateAfter(new Date('1/1/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
date | Date | 허용되지 않는 가장 늦은 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date Before(date)
지정된 값보다 이전 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date before January 1, 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateBefore(new Date('1/1/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
date | Date | 허용되지 않는 가장 빠른 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date Between(start, end)
지정된 두 날짜 사이의 날짜 또는 두 날짜 중 하나를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date in 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateBetween(new Date('1/1/2013'), new Date('12/31/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
start | Date | 허용되는 가장 빠른 날짜입니다. |
end | Date | 허용되는 가장 늦은 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date Equal To(date)
지정된 값과 동일한 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date equal to January 1, // 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateEqualTo(new Date('1/1/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
date | Date | 유일하게 허용되는 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date Not Between(start, end)
지정된 두 날짜 사이 또는 지정된 두 날짜가 아닌 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date not in 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateNotBetween(new Date('1/1/2013'), new Date('12/31/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
start | Date | 허용되지 않는 가장 빠른 날짜입니다. |
end | Date | 허용되지 않는 가장 늦은 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date On Or After(date)
지정된 값 이후의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date on or after January 1, // 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateOnOrAfter(new Date('1/1/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
date | Date | 허용되는 가장 빠른 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Date On Or Before(date)
지정된 값 이전의 날짜를 요구하도록 데이터 유효성 검사 규칙을 설정합니다. Date 객체의 시간 필드는 무시됩니다. 일, 월, 연도 필드만 사용됩니다.
// Set the data validation for cell A1 to require a date on or before January 1, // 2013. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireDateOnOrBefore(new Date('1/1/2013')) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
date | Date | 허용되는 가장 늦은 날짜입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Formula Satisfied(formula)
지정된 수식이 true으로 평가되도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to equal B1 with a custom formula. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireFormulaSatisfied('=EQ(A1,B1)') .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
formula | String | 입력이 유효한 경우 true로 평가되는 맞춤 수식입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Between(start, end)
지정된 두 숫자 사이의 숫자 또는 지정된 두 숫자 중 하나를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number between 1 and 10. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberBetween(1, 10).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
start | Number | 허용되는 최솟값입니다. |
end | Number | 허용되는 가장 높은 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Equal To(number)
지정된 값과 동일한 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number equal // to 3.1415926536. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberEqualTo(Math.PI).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 유일하게 허용되는 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Greater Than(number)
지정된 값보다 큰 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number greater than 0. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberGreaterThan(0).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 허용되지 않는 가장 높은 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Greater Than Or Equal To(number)
지정된 값보다 크거나 같은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number greater than or equal // to 0. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireNumberGreaterThanOrEqualTo(0) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 허용되는 최솟값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Less Than(number)
지정된 값보다 작은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number less than 0. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberLessThan(0).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 허용되지 않는 최솟값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Less Than Or Equal To(number)
지정된 값보다 작거나 같은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number less than or equal to // 0. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireNumberLessThanOrEqualTo(0) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 허용되는 가장 높은 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Not Between(start, end)
지정된 두 숫자 사이 또는 지정된 두 숫자가 아닌 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number not between 1 and 10. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberNotBetween(1, 10).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
start | Number | 허용되지 않는 최솟값입니다. |
end | Number | 허용되지 않는 가장 높은 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Number Not Equal To(number)
지정된 값과 같지 않은 숫자를 요구하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a number not equal to 0. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireNumberNotEqualTo(0).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
number | Number | 유일하게 허용되지 않는 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Text Contains(text)
입력에 지정된 값이 포함되어야 하는 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require any value that includes // "Google". const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireTextContains('Google').build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
text | String | 입력에 포함되어야 하는 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Text Does Not Contain(text)
입력에 지정된 값이 포함되지 않아야 하는 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require any value that does not // include "@". const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireTextDoesNotContain('@').build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
text | String | 입력에 포함되어서는 안 되는 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Text Equal To(text)
입력이 지정된 값과 같아야 하는 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require "Yes". const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireTextEqualTo('Yes').build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
text | String | 유일하게 허용되는 값입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Text Is Email()
입력값이 이메일 주소 형식이어야 하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require text in the form of an email // address. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireTextIsEmail().build(); cell.setDataValidation(rule);
리턴
Data: 체이닝을 위한 이 빌더
require Text Is Url()
입력이 URL 형식이어야 하도록 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require text in the form of a URL. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation().requireTextIsUrl().build(); cell.setDataValidation(rule);
리턴
Data: 체이닝을 위한 이 빌더
require Value In List(values)
입력이 지정된 값 중 하나와 같아야 하는 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require "Yes" or "No", with a dropdown // menu. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireValueInList(['Yes', 'No']) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
values | String[] | 허용되는 값의 배열입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Value In List(values, showDropdown)
입력이 주어진 값 중 하나와 같아야 하는 데이터 유효성 검사 규칙을 설정하고 드롭다운 메뉴를 숨기는 옵션을 제공합니다.
// Set the data validation for cell A1 to require "Yes" or "No", with no // dropdown menu. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireValueInList(['Yes', 'No'], false) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
values | String[] | 허용되는 값의 배열입니다. |
show | Boolean | 스프레드시트에 값의 드롭다운 메뉴를 표시해야 하는 경우 true이고 표시하지 않아야 하는 경우 false입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Value In Range(range)
입력이 지정된 범위의 값과 같아야 하는 데이터 유효성 검사 규칙을 설정합니다.
// Set the data validation for cell A1 to require a value from B1:B10, with a // dropdown menu. const cell = SpreadsheetApp.getActive().getRange('A1'); const range = SpreadsheetApp.getActive().getRange('B1:B10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
range | Range | 허용되는 값이 포함된 범위입니다. |
리턴
Data: 체이닝을 위한 이 빌더
require Value In Range(range, showDropdown)
입력값이 지정된 범위의 값과 같아야 하는 데이터 유효성 검사 규칙을 설정하고 드롭다운 메뉴를 숨기는 옵션을 제공합니다.
// Set the data validation for cell A1 to require value from B1:B10, with no // dropdown menu. const cell = SpreadsheetApp.getActive().getRange('A1'); const range = SpreadsheetApp.getActive().getRange('B1:B10'); const rule = SpreadsheetApp.newDataValidation() .requireValueInRange(range, false) .build(); cell.setDataValidation(rule);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
range | Range | 허용되는 값이 포함된 범위입니다. |
show | Boolean | 스프레드시트에 값의 드롭다운 메뉴를 표시해야 하는 경우 true이고 표시하지 않아야 하는 경우 false입니다. |
리턴
Data: 체이닝을 위한 이 빌더
set Allow Invalid(allowInvalidData)
입력 데이터 유효성 검사에 실패할 때 경고를 표시할지 또는 입력을 완전히 거부할지 설정합니다. 새 데이터 확인 규칙의 기본값은 true입니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
allow | Boolean | 규칙에서 데이터 유효성 검사에 실패한 입력을 허용해야 하는 경우 true이고, 그렇지 않은 경우 false입니다. |
리턴
Data: 체이닝을 위한 이 빌더
set Help Text(helpText)
사용자가 데이터 유효성 검사가 설정된 셀 위로 마우스를 가져갈 때 표시되는 도움말 텍스트를 설정합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
help | String | 설정할 도움말 텍스트입니다. |
리턴
Data: 체이닝을 위한 이 빌더
with Criteria(criteria, args)
데이터 유효성 검사 규칙을 Data 값으로 정의된 기준으로 설정합니다. 일반적으로 기존 규칙의 criteria 및 arguments에서 가져옵니다.
// 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);
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
criteria | Data | 데이터 유효성 검사 기준의 유형입니다. |
args | Object[] | 기준 유형에 적합한 인수 배열입니다. 인수의 개수와 유형은 위에 나온 상응하는 require...() 메서드와 일치합니다. |
리턴
Data: 체이닝을 위한 이 빌더