Allow number selector selection to be None
This commit is contained in:
parent
6f425c6c06
commit
b6f52c1e83
2 changed files with 6 additions and 2 deletions
|
@ -207,8 +207,11 @@ class NumberSelector(Selector):
|
|||
has_min_max_if_slider,
|
||||
)
|
||||
|
||||
def __call__(self, data: Any) -> float:
|
||||
def __call__(self, data: Any) -> float | None:
|
||||
"""Validate the passed selection."""
|
||||
if data is None:
|
||||
return data
|
||||
|
||||
value: float = vol.Coerce(float)(data)
|
||||
|
||||
if "min" in self.config and value < self.config["min"]:
|
||||
|
|
|
@ -208,7 +208,8 @@ def test_area_selector_schema(schema, valid_selections, invalid_selections):
|
|||
(),
|
||||
),
|
||||
({"min": 10, "max": 1000, "mode": "slider", "step": 0.5}, (), ()),
|
||||
({"mode": "box"}, (10,), ()),
|
||||
({"mode": "box"}, (10, None), ("cat")),
|
||||
({"mode": "slider", "min": -100, "max": 100}, (10, None), ("cat")),
|
||||
),
|
||||
)
|
||||
def test_number_selector_schema(schema, valid_selections, invalid_selections):
|
||||
|
|
Loading…
Add table
Reference in a new issue