I want to create DataValidation for a cell in google sheets with google app scripts, but i cannot find the syntax to create a custum formula for the validation.
My idea is to create a code to validate a time format HH:MM. For this matter i already have a a working Regexp (function CheckRegexp)
The only documentation i´ve found so far to this issue is this one: https://developers.google.com/apps-script/reference/spreadsheet/data-validation-criteria
function test() {
var sheet = SpreadsheetApp.getActiveSheet();
var cell = sheet.getRange("E4");
var criteria = SpreadsheetApp.DataValidationCriteria.CUSTOM_FORMULA
//Custom formula CheckRegexp
var dv = SpreadsheetApp.newDataValidation().withCriteria(criteria, args).build();
cell.setDataValidation(dv);
}
function CheckRegexp(input) {
return /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/.test(input);
}
I want the result to be a Data Validation for my Regexp in a desire range.