Skip to content

Commit f85ccd0

Browse files
committed
Merge branch 'main' into 48
2 parents eadc911 + acb4629 commit f85ccd0

File tree

97 files changed

+588
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+588
-431
lines changed

flask_inputfilter/conditions/array_length_equal_condition.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class ArrayLengthEqualCondition(BaseCondition):
1616
1717
**Expected Behavior:**
1818
19-
Validates that the length of the array from ``first_array_field`` is equal to the length of the array from ``second_array_field``. If not, the condition fails.
19+
Validates that the length of the array from ``first_array_field`` is
20+
equal to the length of the array from ``second_array_field``. If not,
21+
the condition fails.
2022
2123
**Example Usage:**
2224
@@ -36,7 +38,12 @@ def __init__(self):
3638
validators=[IsArrayValidator()]
3739
)
3840
39-
self.add_condition(ArrayLengthEqualCondition('list1', 'list2'))
41+
self.add_condition(
42+
ArrayLengthEqualCondition(
43+
first_array_field='list1',
44+
second_array_field='list2'
45+
)
46+
)
4047
"""
4148

4249
__slots__ = ("first_array_field", "second_array_field")

flask_inputfilter/conditions/array_longer_than_condition.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ArrayLongerThanCondition(BaseCondition):
99
"""
10-
Checks if the array in one field is longer than the array in
11-
another field.
10+
Checks if the array in one field is longer than the array in another field.
1211
1312
**Parameters:**
1413
@@ -17,7 +16,8 @@ class ArrayLongerThanCondition(BaseCondition):
1716
1817
**Expected Behavior:**
1918
20-
Validates that the array in ``longer_field`` has more elements than the array in ``shorter_field``.
19+
Validates that the array in ``longer_field`` has more elements than
20+
the array in ``shorter_field``.
2121
2222
**Example Usage:**
2323
@@ -37,7 +37,12 @@ def __init__(self):
3737
validators=[IsArrayValidator()]
3838
)
3939
40-
self.add_condition(ArrayLongerThanCondition('list1', 'list2'))
40+
self.add_condition(
41+
ArrayLongerThanCondition(
42+
longer_field='list1',
43+
shorter_field='list2'
44+
)
45+
)
4146
"""
4247

4348
__slots__ = ("longer_field", "shorter_field")

flask_inputfilter/conditions/custom_condition.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88

99
class CustomCondition(BaseCondition):
1010
"""
11-
Allows defining a custom condition using a user-provided
12-
callable.
11+
Allows defining a custom condition using a user-provided callable.
1312
1413
**Parameters:**
1514
16-
- **condition** (*Callable[[Dict[str, Any]], bool]*): A function that takes the input data and returns a boolean indicating whether the condition is met.
15+
- **condition** (*Callable[[Dict[str, Any]], bool]*): A function that
16+
takes the input data and returns a boolean indicating whether the
17+
condition is met.
1718
1819
**Expected Behavior:**
1920
20-
Executes the provided callable with the input data. The condition passes if the callable returns ``True``, and fails otherwise.
21+
Executes the provided callable with the input data. The condition passes
22+
if the callable returns ``True``, and fails otherwise.
2123
2224
**Example Usage:**
2325
@@ -35,7 +37,11 @@ def __init__(self):
3537
validators=[IsIntegerValidator()]
3638
)
3739
38-
self.add_condition(CustomCondition(my_custom_condition))
40+
self.add_condition(
41+
CustomCondition(
42+
condition=my_custom_condition
43+
)
44+
)
3945
"""
4046

4147
__slots__ = ("condition",)

flask_inputfilter/conditions/equal_condition.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class EqualCondition(BaseCondition):
1616
1717
**Expected Behavior:**
1818
19-
Validates that the values of ``first_field`` and ``second_field`` are equal. Fails if they differ.
19+
Validates that the values of ``first_field`` and ``second_field`` are
20+
equal. Fails if they differ.
2021
2122
**Example Usage:**
2223
@@ -34,7 +35,12 @@ def __init__(self):
3435
'confirm_password'
3536
)
3637
37-
self.add_condition(EqualCondition('password', 'confirm_password'))
38+
self.add_condition(
39+
EqualCondition(
40+
first_field='password',
41+
second_field='confirm_password'
42+
)
43+
)
3844
"""
3945

4046
__slots__ = ("first_field", "second_field")

flask_inputfilter/conditions/exactly_n_of_condition.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class ExactlyNOfCondition(BaseCondition):
99
"""
10-
Checks that exactly ``n`` of the specified fields are present in
11-
the input data.
10+
Checks that exactly ``n`` of the specified fields are present in the input
11+
data.
1212
1313
**Parameters:**
1414
@@ -17,7 +17,8 @@ class ExactlyNOfCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Counts the number of specified fields present in the data and validates that the count equals ``n``.
20+
Counts the number of specified fields present in the data and
21+
validates that the count equals ``n``.
2122
2223
**Example Usage:**
2324
@@ -39,7 +40,12 @@ def __init__(self):
3940
'field3'
4041
)
4142
42-
self.add_condition(ExactlyNOfCondition(['field1', 'field2', 'field3'], 2))
43+
self.add_condition(
44+
ExactlyNOfCondition(
45+
fields=['field1', 'field2', 'field3'],
46+
n=2
47+
)
48+
)
4349
"""
4450

4551
__slots__ = ("fields", "n")

flask_inputfilter/conditions/exactly_n_of_matches_condition.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ExactlyNOfMatchesCondition(BaseCondition):
99
"""
10-
Checks that exactly ``n`` of the specified fields match a given
11-
value.
10+
Checks that exactly ``n`` of the specified fields match a given value.
1211
1312
**Parameters:**
1413
@@ -18,7 +17,8 @@ class ExactlyNOfMatchesCondition(BaseCondition):
1817
1918
**Expected Behavior:**
2019
21-
Validates that exactly ``n`` fields among the specified ones have the given value.
20+
Validates that exactly ``n`` fields among the specified ones have the
21+
given value.
2222
2323
**Example Usage:**
2424
@@ -36,7 +36,13 @@ def __init__(self):
3636
'field2'
3737
)
3838
39-
self.add_condition(ExactlyNOfMatchesCondition(['field1', 'field2'], 1, 'expected_value'))
39+
self.add_condition(
40+
ExactlyNOfMatchesCondition(
41+
fields=['field1', 'field2'],
42+
n=1,
43+
value='expected_value'
44+
)
45+
)
4046
"""
4147

4248
__slots__ = ("fields", "n", "value")

flask_inputfilter/conditions/exactly_one_of_condition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class ExactlyOneOfCondition(BaseCondition):
1515
1616
**Expected Behavior:**
1717
18-
Validates that only one field among the specified fields exists in the input data.
18+
Validates that only one field among the specified fields exists in the
19+
input data.
1920
2021
**Example Usage:**
2122

flask_inputfilter/conditions/exactly_one_of_matches_condition.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
class ExactlyOneOfMatchesCondition(BaseCondition):
99
"""
10-
Ensures that exactly one of the specified fields matches a given
11-
value.
10+
Ensures that exactly one of the specified fields matches a given value.
1211
1312
**Parameters:**
1413
@@ -35,7 +34,12 @@ def __init__(self):
3534
'option2'
3635
)
3736
38-
self.add_condition(ExactlyOneOfMatchesCondition(['option1', 'option2'], 'yes'))
37+
self.add_condition(
38+
ExactlyOneOfMatchesCondition(
39+
fields=['option1', 'option2'],
40+
value='yes'
41+
)
42+
)
3943
"""
4044

4145
__slots__ = ("fields", "value")

flask_inputfilter/conditions/integer_bigger_than_condition.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class IntegerBiggerThanCondition(BaseCondition):
99
"""
10-
Checks if the integer value in one field is greater than that in
11-
another field.
10+
Checks if the integer value in one field is greater than that in another
11+
field.
1212
1313
**Parameters:**
1414
@@ -17,7 +17,8 @@ class IntegerBiggerThanCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Validates that the integer value from ``bigger_field`` is greater than the value from ``smaller_field``.
20+
Validates that the integer value from ``bigger_field`` is greater than
21+
the value from ``smaller_field``.
2122
2223
**Example Usage:**
2324
@@ -37,7 +38,12 @@ def __init__(self):
3738
validators=[IsIntegerValidator()]
3839
)
3940
40-
self.add_condition(IntegerBiggerThanCondition('field_should_be_bigger', 'field_should_be_smaller'))
41+
self.add_condition(
42+
IntegerBiggerThanCondition(
43+
bigger_field='field_should_be_bigger',
44+
smaller_field='field_should_be_smaller'
45+
)
46+
)
4147
"""
4248

4349
__slots__ = ("bigger_field", "smaller_field")

flask_inputfilter/conditions/n_of_condition.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class NOfCondition(BaseCondition):
99
"""
10-
Checks that at least ``n`` of the specified fields are present in
11-
the input data.
10+
Checks that at least ``n`` of the specified fields are present in the input
11+
data.
1212
1313
**Parameters:**
1414
@@ -17,7 +17,8 @@ class NOfCondition(BaseCondition):
1717
1818
**Expected Behavior:**
1919
20-
Validates that the count of the specified fields present is greater than or equal to ``n``.
20+
Validates that the count of the specified fields present is greater
21+
than or equal to ``n``.
2122
2223
**Example Usage:**
2324
@@ -39,7 +40,12 @@ def __init__(self):
3940
'field3'
4041
)
4142
42-
self.add_condition(NOfCondition(['field1', 'field2', 'field3'], 2))
43+
self.add_condition(
44+
NOfCondition(
45+
fields=['field1', 'field2', 'field3'],
46+
n=2
47+
)
48+
)
4349
"""
4450

4551
__slots__ = ("fields", "n")

0 commit comments

Comments
 (0)