Skip to content

Commit 783a6e5

Browse files
Merge pull request #15 from SlicingDice/feature/adapt-method-to-receive-list-of-fields
Adapt method to receive list of fields
2 parents 6834a54 + f8ab834 commit 783a6e5

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

pyslicer/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def create_field(self, data):
164164
"""Create field in Slicing Dice
165165
166166
Keyword arguments:
167-
data -- A dictionary in the Slicing Dice field
167+
data -- A dictionary or list on the Slicing Dice field
168168
format.
169169
"""
170170
base_url = self._wrapper_test()

pyslicer/utils/validators.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,20 @@ def validator(self):
260260

261261

262262
class FieldValidator(SDBaseValidator):
263-
def __init__(self, dictionary_field):
263+
def __init__(self, data_field):
264264
"""
265265
Parameters:
266-
dictionary_field(dict) -- A dict field
266+
data_field -- A dict or list of fields
267267
"""
268-
super(FieldValidator, self).__init__(dictionary_field)
269-
self._valid_type_fields = [
270-
"unique-id", "boolean", "string", "integer", "decimal",
271-
"enumerated", "date", "integer-time-series",
272-
"decimal-time-series", "string-time-series"
273-
]
268+
if not isinstance(data_field, list):
269+
data_field = [data_field]
270+
for dictionary_field in data_field:
271+
super(FieldValidator, self).__init__(dictionary_field)
272+
self._valid_type_fields = [
273+
"unique-id", "boolean", "string", "integer", "decimal",
274+
"enumerated", "date", "integer-time-series",
275+
"decimal-time-series", "string-time-series"
276+
]
274277

275278
def _validate_name(self):
276279
"""Validate field name"""

0 commit comments

Comments
 (0)