Skip to content

Commit 2917baa

Browse files
committed
Fix issue with route params
1 parent 6e14f20 commit 2917baa

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

docs/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ Changelog
33

44
All notable changes to this project will be documented in this file.
55

6+
7+
[0.0.9.1] - 2025-02-09
8+
----------------------
9+
10+
Changed
11+
^^^^^^^
12+
13+
- Updated ``InputFilter`` to fix the issue with route params.
14+
15+
616
[0.0.9] - 2025-01-29
717
--------------------
818

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
project = "flask-inputfilter"
1010
copyright = "2025, Leander Cain Slotosch"
1111
author = "Leander Cain Slotosch"
12-
release = "0.0.9"
12+
release = "0.0.9.1"
1313

1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

flask_inputfilter/InputFilter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,20 @@ def __checkConditions(self, validated_data: dict) -> None:
269269
raise ValidationError(f"Condition '{condition}' not met.")
270270

271271
@final
272-
def validateData(self, data: Dict[str, Any]) -> Dict[str, Any]:
272+
def validateData(self, data: Dict[str, Any], kwargs: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
273273
"""
274274
Validate the input data, considering both request data and
275275
URL parameters (kwargs).
276276
"""
277277

278+
if kwargs is None:
279+
kwargs = {}
280+
278281
validated_data = {}
282+
combined_data = {**data, **kwargs}
279283

280284
for field_name, field_info in self.fields.items():
281-
value = data.get(field_name)
285+
value = combined_data.get(field_name)
282286

283287
required = field_info["required"]
284288
default = field_info["default"]
@@ -344,7 +348,7 @@ def wrapper(
344348
data = request.json if request.is_json else request.args
345349

346350
try:
347-
g.validated_data = input_filter.validateData(data)
351+
g.validated_data = input_filter.validateData(data, kwargs)
348352

349353
except ValidationError as e:
350354
return Response(status=400, response=str(e))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="flask_inputfilter",
5-
version="0.0.9",
5+
version="0.0.9.1",
66
author="Leander Cain Slotosch",
77
author_email="[email protected]",
88
description="A library to filter and validate input data in"

test/test_input_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def setUp(self) -> None:
3333
def test_validate_decorator(self, mock_validateData) -> None:
3434
mock_validateData.return_value = {"username": "test_user", "age": 25}
3535

36-
app = Flask(__name__)
37-
3836
class MyInputFilter(InputFilter):
3937
def __init__(self):
4038
super().__init__()
@@ -49,6 +47,8 @@ def __init__(self):
4947
validators=[IsIntegerValidator()],
5048
)
5149

50+
app = Flask(__name__)
51+
5252
@app.route("/test", methods=["GET", "POST"])
5353
@MyInputFilter.validate()
5454
def test_route():

0 commit comments

Comments
 (0)