Skip to content

Commit

Permalink
fix when_value check
Browse files Browse the repository at this point in the history
  • Loading branch information
marcohong committed Sep 9, 2020
1 parent 58d4bd3 commit adf87d7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xform/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self,
validate: Any = None,
err_msg: str = None,
when_field: str = None,
when_value: Union[list, tuple] = None,
when_value: Any = None,
**kwargs: Any) -> None:
'''
:param data_key: `<str>` submit form parameters key, default field name
Expand All @@ -59,7 +59,8 @@ def __init__(self,
'invalid':'name is invalid.'
}
:param when_field: `<str>` others params field
:param when_value: `<Any>` if when_value, required is True.
:param when_value: `<Any>` callable/list/tuple/str/bool/int
if when_value, required is True.
e.g:
# callable, return bool
id=fiels.Integer(required=False, default=0)
Expand All @@ -82,9 +83,8 @@ def __init__(self,
self.length = length
self.lst = lst
self.when_field = when_field
if when_field and (not when_value or
not isinstance(when_value, (list, tuple))):
raise ValueError('when_value invalid, must be an array or tuple')
if when_field and not when_value:
raise ValueError('when_value invalid')
self.when_value = when_value
self.kwargs = kwargs
self.null_values = (None, '',)
Expand Down

0 comments on commit adf87d7

Please sign in to comment.