Skip to content

Commit

Permalink
don't replace empty validation dicts with new instances (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Dec 25, 2023
1 parent 9a0811a commit 7ec8b5e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nicegui/elements/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self,
:param autocomplete: optional list of strings for autocompletion
:param validation: dictionary of validation rules, e.g. ``{'Too long!': lambda value: len(value) < 3}``
"""
super().__init__(value=value, on_value_change=on_change, validation=validation or {})
super().__init__(value=value, on_value_change=on_change, validation=validation)
if label is not None:
self._props['label'] = label
if placeholder is not None:
Expand Down
4 changes: 2 additions & 2 deletions nicegui/elements/mixins/validation_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

class ValidationElement(ValueElement):

def __init__(self, validation: Dict[str, Callable[..., bool]], **kwargs: Any) -> None:
def __init__(self, validation: Optional[Dict[str, Callable[..., bool]]], **kwargs: Any) -> None:
super().__init__(**kwargs)
self.validation = validation
self.validation = validation if validation is not None else {}
self._error: Optional[str] = None

@property
Expand Down
2 changes: 1 addition & 1 deletion nicegui/elements/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self,
:param validation: dictionary of validation rules, e.g. ``{'Too large!': lambda value: value < 3}``
"""
self.format = format
super().__init__(tag='q-input', value=value, on_value_change=on_change, validation=validation or {})
super().__init__(tag='q-input', value=value, on_value_change=on_change, validation=validation)
self._props['type'] = 'number'
if label is not None:
self._props['label'] = label
Expand Down
2 changes: 1 addition & 1 deletion nicegui/elements/textarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def __init__(self,
:param on_change: callback to execute when the value changes
:param validation: dictionary of validation rules, e.g. ``{'Too long!': lambda value: len(value) < 3}``
"""
super().__init__(label, placeholder=placeholder, value=value, on_change=on_change, validation=validation or {})
super().__init__(label, placeholder=placeholder, value=value, on_change=on_change, validation=validation)
self._props['type'] = 'textarea'

0 comments on commit 7ec8b5e

Please sign in to comment.