@@ -280,6 +280,7 @@ def make_klass(spec):
280
280
def custom_validator (instance , attribute , value ):
281
281
"""simple custom validation
282
282
take into account ty.Union, ty.List, ty.Dict (but only one level depth)
283
+ adding an additional validator, if allowe_values provided
283
284
"""
284
285
validators = []
285
286
tp_attr = attribute .type
@@ -333,6 +334,12 @@ def custom_validator(instance, attribute, value):
333
334
334
335
335
336
def _type_validator (instance , attribute , value , tp , cont_type ):
337
+ """ creating a customized type validator,
338
+ uses validator.deep_iterable/mapping if the field is a container
339
+ (i.e. ty.List or ty.Dict),
340
+ it also tries to guess when the value is a list due to the splitter
341
+ and validates the elements
342
+ """
336
343
if cont_type is None or cont_type is ty .Union :
337
344
# if tp is not (list,), we are assuming that the value is a list
338
345
# due to the splitter, so checking the member types
@@ -364,7 +371,7 @@ def _type_validator(instance, attribute, value, tp, cont_type):
364
371
365
372
366
373
def _types_updates (tp_list , name ):
367
- """updating the tuple with possible types"""
374
+ """updating the type's tuple with possible additional types"""
368
375
tp_upd_list = []
369
376
check = True
370
377
for tp_el in tp_list :
@@ -379,8 +386,9 @@ def _types_updates(tp_list, name):
379
386
380
387
381
388
def _single_type_update (tp , name , simplify = False ):
382
- """ updating a single type - e.g. adding bytes if str is required
389
+ """ updating a single type with other related types - e.g. adding bytes for str
383
390
if simplify is True, than changing typing.List to list etc.
391
+ (assuming that I validate only one depth, so have to simplify at some point)
384
392
"""
385
393
if isinstance (tp , type ) or tp in [File , Directory ]:
386
394
if tp is str :
0 commit comments