Complete the code to apply a data validation rule that allows only numbers between 1 and 10.
dataValidation = SpreadsheetApp.newDataValidation().requireNumberBetween([1], 10).build()
The requireNumberBetween method needs the minimum number as the first argument. Here, 1 is the minimum allowed value.
Complete the code to set a data validation rule that only allows text values from a list of options.
dataValidation = SpreadsheetApp.newDataValidation().requireValueInList([1], true).build()The requireValueInList method expects an array of strings as the first argument. So, the list must be inside square brackets and each option in quotes.
Fix the error in the code to require a checkbox data validation.
dataValidation = SpreadsheetApp.newDataValidation().requireCheckbox([1]).build()The requireCheckbox method takes a boolean argument to indicate if the checkbox is checked or unchecked by default. It must be the boolean true or false, not a string or number.
Complete the code to create a data validation rule that only allows dates after January 1, 2023.
dataValidation = SpreadsheetApp.newDataValidation().requireDateAfter([1]).build()Date() without new keyword.Date.parse() which returns a number, not a Date object.The requireDateAfter method expects a JavaScript Date object. Using new Date('2023-01-01') creates the correct date object.
Fill all three blanks to create a data validation rule that requires a number between 5 and 15 and shows custom help text.
dataValidation = SpreadsheetApp.newDataValidation().requireNumberBetween([1], [2]).setHelpText([3]).build()
The requireNumberBetween method needs the minimum and maximum numbers as the first two arguments. The setHelpText method sets the custom help text shown to users.