Skip to content

Commit

Permalink
finsihed the method
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 committed Mar 15, 2024
1 parent 3260f83 commit c3a9974
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions gspread/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3201,21 +3201,36 @@ def cut_range(
return self.client.batch_update(self.spreadsheet_id, body)

def add_validation(
self, range: str, validation_type: Any, *values,
self,
range: str,
validation_type: Any,
*values,
**kwargs,
) -> Any:
"""
Adds a data validation to any given ranges.
"""
grid = a1_range_to_grid_range(range, self.id)

body = {
"requests": [{
'setDataValidation': {
'range': grid,
'rule': {
'condition': {
'type': validation_type,
'values': [{'userEnteredValue': value} for value in values]
}

"requests": [
{
"setDataValidation": {
"range": grid,
"rule": {
"condition": {
"type": validation_type,
"values": [
{"userEnteredValue": value} for value in values
],
}
},
**kwargs
}
}
}],
],
}

self.client.batch_update(self.spreadsheet_id, body)

0 comments on commit c3a9974

Please sign in to comment.