Assigned
Status Update
Comments
[Deleted User] <[Deleted User]> #2
I'd also love to see this as a formula, in order to apply conditional formatting based on the whether the content of a cell passes the data validation rule or not. Something like ISVALID(value).
[Deleted User] <[Deleted User]> #3
I'm completely baffled: what's the point of "Data Validation" if there's no way of checking whether the data satisfies the condition? Could we all be missing something?
be...@gmail.com <be...@gmail.com> #4
@marc.art: The validation still validates within the UI itself; it's just that the results of the validation aren't available in code.
ke...@gmail.com <ke...@gmail.com> #5
This would be extremely helpful! Im looking to optimize my team's workflow and it is counterintuitive and wasteful on resources to reverse engineer the validation just to check if it is valid when that information is already shown in the UI! Please add .isValid()!!
si...@swoop.com <si...@swoop.com> #6
This is a blocking feature for implementing a compliance changelog of only valid entries.
ry...@google.com <ry...@google.com>
ca...@gmail.com <ca...@gmail.com> #7
Would definitely be useful.
ke...@smallmeans.net <ke...@smallmeans.net> #8
Can't see why this isn't already available. I hope it is added soon!
gk...@gmail.com <gk...@gmail.com> #9
I've created a workaround for this issue that works in a very ugly -technically said- and slightly undetermined way.
My problem is that the validation is already done by the SpreadsheetApp, but only visually accessible by the user. It feels like that "you can see but cannot touch" :) It's against the whole idea of GAS.
I'd really love to have this result accessible (the feature implemented).
About the workaround:
It works based on the experience that the web browser implementation of catch() function allows to access thrown errors by the script editor JS code parts.
In case an invalid input into a cell is rejected by a validation rule then the system will display an error message that is catchable by the user written GAS. In order to make it work first the reject value has to be set on the specified cell then its vale has to be re-entered (modified) then -right after this- calling the getDataValidation() built in function allows us to catch the necessary error.
Only single cells can be tested with this method as setCellValues() ignores any data validation restriction (as of today).
Disadvantages:
- The validity won't be necessarily re-checked for this function: checking cell validity right after the value is inserted into it. Therefore the result of this function might be faulty.
- The code messes up the history as cells will be changed - in case they are valid.
I've tested it successfully on both Firefox and Chromium.
function getCellValidity(cell) {
var origValidRule = cell.getDataValidation();
if (origValidRule == null || ! (cell.getNumRows() == cell.getNumColumns() == 1)) {
return null;
}
var cell_value = cell.getValue();
if (cell_value === '') return true; // empty cell is always valid
var is_valid = true;
var cell_formula = cell.getFormula();
// Storing and checking if cell validation is set to allow invalid input with a warning or reject it
var reject_invalid = ! origValidRule.getAllowInvalid();
// If invalid value is allowed (just warning), then changing validation to reject it
// IMPORTANT: this will not throw an error!
if (! reject_invalid) {
var rejectValidRule = origValidRule.copy().setAllowInvalid(false).build();
cell.setDataValidation(rejectValidRule);
}
// Re-entering value or formula into the cell itself
var cell_formula = cell.getFormula();
if (cell_formula !== '') {
cell.setFormula(cell_formula);
} else {
cell.setValue(cell_value);
}
try {
var tempValidRule = cell.getDataValidation();
} catch(e) {
// Exception: The data that you entered in cell XY violates the data validation rules set on this cell.
// where XY is the A1 style address of the cell
is_valid = false;
}
// Restoring original rule
if (rejectValidRule != null) {
cell.setDataValidation(origValidRule.copy().setAllowInvalid(true).build());
}
return is_valid;
}
Finally let me express my gratitude for all the great works of the developers! With their shared tools/system I can solve many logistical problems of my and others' lives... Cheers!
On this issue: Hurry up guys!
My problem is that the validation is already done by the SpreadsheetApp, but only visually accessible by the user. It feels like that "you can see but cannot touch" :) It's against the whole idea of GAS.
I'd really love to have this result accessible (the feature implemented).
About the workaround:
It works based on the experience that the web browser implementation of catch() function allows to access thrown errors by the script editor JS code parts.
In case an invalid input into a cell is rejected by a validation rule then the system will display an error message that is catchable by the user written GAS. In order to make it work first the reject value has to be set on the specified cell then its vale has to be re-entered (modified) then -right after this- calling the getDataValidation() built in function allows us to catch the necessary error.
Only single cells can be tested with this method as setCellValues() ignores any data validation restriction (as of today).
Disadvantages:
- The validity won't be necessarily re-checked for this function: checking cell validity right after the value is inserted into it. Therefore the result of this function might be faulty.
- The code messes up the history as cells will be changed - in case they are valid.
I've tested it successfully on both Firefox and Chromium.
function getCellValidity(cell) {
var origValidRule = cell.getDataValidation();
if (origValidRule == null || ! (cell.getNumRows() == cell.getNumColumns() == 1)) {
return null;
}
var cell_value = cell.getValue();
if (cell_value === '') return true; // empty cell is always valid
var is_valid = true;
var cell_formula = cell.getFormula();
// Storing and checking if cell validation is set to allow invalid input with a warning or reject it
var reject_invalid = ! origValidRule.getAllowInvalid();
// If invalid value is allowed (just warning), then changing validation to reject it
// IMPORTANT: this will not throw an error!
if (! reject_invalid) {
var rejectValidRule = origValidRule.copy().setAllowInvalid(false).build();
cell.setDataValidation(rejectValidRule);
}
// Re-entering value or formula into the cell itself
var cell_formula = cell.getFormula();
if (cell_formula !== '') {
cell.setFormula(cell_formula);
} else {
cell.setValue(cell_value);
}
try {
var tempValidRule = cell.getDataValidation();
} catch(e) {
// Exception: The data that you entered in cell XY violates the data validation rules set on this cell.
// where XY is the A1 style address of the cell
is_valid = false;
}
// Restoring original rule
if (rejectValidRule != null) {
cell.setDataValidation(origValidRule.copy().setAllowInvalid(true).build());
}
return is_valid;
}
Finally let me express my gratitude for all the great works of the developers! With their shared tools/system I can solve many logistical problems of my and others' lives... Cheers!
On this issue: Hurry up guys!
to...@gmail.com <to...@gmail.com> #10
I'm desperate for this method to be added! Please please please do it soonest possible! Thank you!
co...@beetstech.com <co...@beetstech.com> #11
Yes please implement this. I suppose the data could be checked against the data validation rules before setting the values, but that would really slow the write process down. Not to mention how much of a pain it would be to code all the validity checks to accommodate all the different possible data validation rules.
I've been starting to use Google Sheets to serve some of our company's data storage in place of data typically stored in a SQL database, but the hard data validation rules are an essential part to maintaining data integrity in the way that's possible with a SQL database.
I've been starting to use Google Sheets to serve some of our company's data storage in place of data typically stored in a SQL database, but the hard data validation rules are an essential part to maintaining data integrity in the way that's possible with a SQL database.
[Deleted User] <[Deleted User]> #12
Please add this. It will bring down so much bad code that I have put in place due to lack of this function.
wl...@gmail.com <wl...@gmail.com> #13
Please add this in asimple manner: isValid() true or false
ri...@gmail.com <ri...@gmail.com> #14
I would say the methis should be intiutive to read.
Range.dataValidate() :: [][]bool
Since we are doing DataValidations ...
Range.dataValidate() :: [][]bool
Since we are doing DataValidations ...
mi...@gmail.com <mi...@gmail.com> #15
I need it like a thirsty desert traveler needs a few drops of water.
[Deleted User] <[Deleted User]> #16
I need it like a few drops of water need hydrogen and oxygen
vo...@depotndg.org <vo...@depotndg.org> #17
Must I beg?
[Deleted User] <[Deleted User]> #18
Seems that begging is necessary...
[Deleted User] <[Deleted User]> #19
Also require this, so i can track any validations fails centrally, without logging into each spreadsheet and sheet to check which is time consuming.
[Deleted User] <[Deleted User]> #20
OK Google... We know you can do it !
me...@gmail.com <me...@gmail.com> #21
Nearly 5 years later and still no change..
I don't think this will happen
I don't think this will happen
gi...@gmail.com <gi...@gmail.com> #22
+1
jo...@fuel-rod.com <jo...@fuel-rod.com> #23
It would be very cool
ya...@danielzrihen.co.il <ya...@danielzrihen.co.il> #24
+1
jo...@gmail.com <jo...@gmail.com> #25
+1
pe...@gmail.com <pe...@gmail.com> #26
+1
ma...@gmail.com <ma...@gmail.com> #27
+1
ch...@gmail.com <ch...@gmail.com> #28
+1
dp...@hotelbotanico.com <dp...@hotelbotanico.com> #29
+1
[Deleted User] <[Deleted User]> #30
+1
gu...@gmail.com <gu...@gmail.com> #31
+1
an...@gmail.com <an...@gmail.com> #32
+1
[Deleted User] <[Deleted User]> #33
+1
ke...@walkersands.com <ke...@walkersands.com> #34
+1 would be incredibly helpful to just have an ISVALID() formula that returns TRUE has a legit data validation value and FALSE if somebody entered a value into the cell that doesn't match a data validation value. Simple addition to Google Sheets that would make tons of people happy.
[Deleted User] <[Deleted User]> #35
+1 Hoping...
kr...@gmail.com <kr...@gmail.com> #36
This would be extremely helpful!
Strange that it is not yet implemented, or able to get error validation.
+1
Strange that it is not yet implemented, or able to get error validation.
+1
fu...@gmail.com <fu...@gmail.com> #37
+1
gg...@molineschools.org <gg...@molineschools.org> #38
Please add this
[Deleted User] <[Deleted User]> #39
+1
fm...@gmail.com <fm...@gmail.com> #40
+1
hz...@gmail.com <hz...@gmail.com> #41
+1
an...@gmail.com <an...@gmail.com> #42
+1
ko...@gmail.com <ko...@gmail.com> #43
+1
mj...@gmail.com <mj...@gmail.com> #44
+1
be...@gmail.com <be...@gmail.com> #45
+1
fa...@gmail.com <fa...@gmail.com> #46
+1
mr...@gmail.com <mr...@gmail.com> #47
+1
ba...@gmail.com <ba...@gmail.com> #48
+1
[Deleted User] <[Deleted User]> #49
+1
jo...@gmail.com <jo...@gmail.com> #50
+1
gu...@gmail.com <gu...@gmail.com> #51
+1
at...@gmail.com <at...@gmail.com> #52
Is somebody working on this one?
co...@geeksconnect.com <co...@geeksconnect.com> #53
I'm an experienced app developer and just starting w/ Appscript to customize my client's google sheets. I realized that this simple but critical function-- check if a cell value satisfies a data validation, or if satisfies the conditional formatting condition-- is missing!! Really surprised and disappointed. Tried to find a work-around but apparently I couldn't use some very useful built-in functions such as ISEMAIL within appscript. Lack of these features are quite discouraging to diving into Google Workspace Dev seriously. HOPEFULLY this feature will be RELEASE SOON!
le...@gmail.com <le...@gmail.com> #54
+1 for sure!
pd...@gmail.com <pd...@gmail.com> #55
@co...@geeksconnect.com
" HOPEFULLY this feature will be RELEASE SOON!"
Been asked since 2016 with no significant progress.
I think there´s more chance of google redoing their whole platform services (which they do frequently) at this point that getting some of these basic stuff.
Would not hold my code waiting for it.
Best worst solution might be to write your validation as a conditional to a temporary (or permanent) cell and read the value of the result I guess...
Haven´t used this in a while just because it´s not practical.
" HOPEFULLY this feature will be RELEASE SOON!"
Been asked since 2016 with no significant progress.
I think there´s more chance of google redoing their whole platform services (which they do frequently) at this point that getting some of these basic stuff.
Would not hold my code waiting for it.
Best worst solution might be to write your validation as a conditional to a temporary (or permanent) cell and read the value of the result I guess...
Haven´t used this in a while just because it´s not practical.
[Deleted User] <[Deleted User]> #56
+1
pe...@junolive.co <pe...@junolive.co> #57
+1 & holding my breath.
ch...@gmail.com <ch...@gmail.com> #58
+1
lu...@farmaprom.pl <lu...@farmaprom.pl> #59
+!
kh...@gmail.com <kh...@gmail.com> #60
+1
da...@toolsquare.io <da...@toolsquare.io> #61
+1 as well!!
ti...@gmail.com <ti...@gmail.com> #62
+1
de...@va-and-it.com <de...@va-and-it.com> #63
+1
sa...@gmail.com <sa...@gmail.com> #64
+1
[Deleted User] <[Deleted User]> #65
+1
as...@brex.com <as...@brex.com> #66
+1
do...@youngtree.org <do...@youngtree.org> #67
+1
[Deleted User] <[Deleted User]> #68
+1
nr...@gmail.com <nr...@gmail.com> #69
+1
ra...@gmail.com <ra...@gmail.com> #70
+1
an...@gmail.com <an...@gmail.com> #71
+1
da...@dotherightthing.co.nz <da...@dotherightthing.co.nz> #72
+1
ch...@gsa.gov <ch...@gsa.gov> #73
ju...@bbva.com <ju...@bbva.com> #74
+1
ha...@aktsk.com <ha...@aktsk.com> #75
+1
je...@gmail.com <je...@gmail.com> #76
+1
da...@invitae.com <da...@invitae.com> #77
+1. Add isValid() method
bb...@gmail.com <bb...@gmail.com> #78
+1
Above suggested a good hack but "try{} catch(e){}" code section takes a long time ( >120 sec). If it processes 3 cells, then we get "Exceeded maximum execution time".
Need a solution from Google.
Above suggested a good hack but "try{} catch(e){}" code section takes a long time ( >120 sec). If it processes 3 cells, then we get "Exceeded maximum execution time".
Need a solution from Google.
su...@gmail.com <su...@gmail.com> #79
+1
lo...@flocksafety.com <lo...@flocksafety.com> #80
+1
It's unfortunate that after the better part of a decade since the original ask, it's pretty clear Google doesn't seem to have the time of day (or care?) to implement this pretty useful feature. Would enjoy having it nonetheless, so I'll continue the bump.
I checked out the Developer References for Apps Script, there is a DataValidation section that I thought would resolve my use-case, but unfortunately after some experimentation it failed to do the trick. I am using a Data Validation that rejects inputs that are not given in the dropdown menu, however I am using a query-based two-layer data validation dropdown system (in other words, my first drop down menu alters a query range that influences what options my second dropdown menu offers). When I change the selection of the first dropdown to something with new options in the second dropdown menu, the selected option remains even though it is invalid in the second dropdown menu. getAllowInvalid() returns "false" in that it will reject any input that fails validation, however when I use getCriteriaValues() to determine a true/false difference between the first menu (which should be valid and TRUE) and the second menu (which is invalid and should be FALSE) they both return TRUE.
Ergo, the currently implemented system is flawed and does not satisfy the simple requirements that my needs nor the needs of many on this 8-year old tracker. I will be looking into an onEdit script to blank out the second dropdown menu as a bandage fix, but it is exactly that: a bandage.
It's unfortunate that after the better part of a decade since the original ask, it's pretty clear Google doesn't seem to have the time of day (or care?) to implement this pretty useful feature. Would enjoy having it nonetheless, so I'll continue the bump.
I checked out the Developer References for Apps Script, there is a DataValidation section that I thought would resolve my use-case, but unfortunately after some experimentation it failed to do the trick. I am using a Data Validation that rejects inputs that are not given in the dropdown menu, however I am using a query-based two-layer data validation dropdown system (in other words, my first drop down menu alters a query range that influences what options my second dropdown menu offers). When I change the selection of the first dropdown to something with new options in the second dropdown menu, the selected option remains even though it is invalid in the second dropdown menu. getAllowInvalid() returns "false" in that it will reject any input that fails validation, however when I use getCriteriaValues() to determine a true/false difference between the first menu (which should be valid and TRUE) and the second menu (which is invalid and should be FALSE) they both return TRUE.
Ergo, the currently implemented system is flawed and does not satisfy the simple requirements that my needs nor the needs of many on this 8-year old tracker. I will be looking into an onEdit script to blank out the second dropdown menu as a bandage fix, but it is exactly that: a bandage.
sa...@dexterity.ai <sa...@dexterity.ai> #81
Google doesn't care. Share this on twitter... it wont matter. This project is dead. Do much potential lost. The API provided doesn't work as documented. Its broken and will never work. Stop using Google services.
su...@modernizingprocesses.com <su...@modernizingprocesses.com> #82
+1
ng...@gmail.com <ng...@gmail.com> #83
+1
why google doesn't care?
why google doesn't care?
si...@gmail.com <si...@gmail.com> #84
+1 cmon it has been almost 10 years
jo...@bkp.activesoft.com.br <jo...@bkp.activesoft.com.br> #85
+1
op...@usmicroscrew.com <op...@usmicroscrew.com> #86
+1...million
de...@gmail.com <de...@gmail.com> #87
+1
jp...@gmail.com <jp...@gmail.com> #88
+100
fe...@gmail.com <fe...@gmail.com> #89
+1
ad...@esky.com <ad...@esky.com> #90
+100
ne...@starlingbank.com <ne...@starlingbank.com> #91
+++ would be useful. Want to make sure validation requirements are met before running
pl...@gmail.com <pl...@gmail.com> #92
+1
ta...@gmail.com <ta...@gmail.com> #93
+1
Description
a method on Spreadsheet.Range such as .isValid() for single cell or to match the other Range methods more generally .getValidationResult() which might return a Boolean flag for the top left cell in the Range and .getValidationResults() which might return a [][] of Boolean flags for each cell in a Range.
To subsequent readers: If you are also interested in this requested
feature, please click the star next to the issue number.