safeshield 1.4.10__tar.gz → 1.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {safeshield-1.4.10 → safeshield-1.5.1}/PKG-INFO +1 -1
- {safeshield-1.4.10 → safeshield-1.5.1}/safeshield.egg-info/PKG-INFO +1 -1
- {safeshield-1.4.10 → safeshield-1.5.1}/setup.py +1 -1
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/base.py +0 -1
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/comparison.py +6 -7
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/services/rule_error_handler.py +2 -9
- {safeshield-1.4.10 → safeshield-1.5.1}/LICENSE +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/README.md +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/safeshield.egg-info/SOURCES.txt +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/safeshield.egg-info/dependency_links.txt +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/safeshield.egg-info/requires.txt +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/safeshield.egg-info/top_level.txt +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/setup.cfg +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/core/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/core/validator.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/database/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/database/detector.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/database/manager.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/exceptions.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/factory.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/array.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/basic.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/boolean.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/date.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/files.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/format.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/numeric.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/string.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/rules/utilities.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/services/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/services/rule_conflict.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/services/rule_preparer.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/utils/__init__.py +0 -0
- {safeshield-1.4.10 → safeshield-1.5.1}/validator/utils/string.py +0 -0
|
@@ -27,7 +27,7 @@ class MinRule(Rule):
|
|
|
27
27
|
return False
|
|
28
28
|
|
|
29
29
|
def message(self, field: str, params: List[str]) -> str:
|
|
30
|
-
return f"The :attribute must be at least
|
|
30
|
+
return f"The :attribute must be at least :min."
|
|
31
31
|
|
|
32
32
|
class MaxRule(Rule):
|
|
33
33
|
def validate(self, field: str, value: Any, params: List[str]) -> bool:
|
|
@@ -40,7 +40,6 @@ class MaxRule(Rule):
|
|
|
40
40
|
# Handle Werkzeug/Flask FileStorage
|
|
41
41
|
if hasattr(value, 'content_length'): # Flask/Werkzeug
|
|
42
42
|
file_size = value.content_length
|
|
43
|
-
print(f"File size (content_length): {file_size}")
|
|
44
43
|
return file_size <= max_val
|
|
45
44
|
|
|
46
45
|
# Handle generic file objects with size attribute
|
|
@@ -85,13 +84,13 @@ class MaxRule(Rule):
|
|
|
85
84
|
def message(self, field: str, params: List[str]) -> str:
|
|
86
85
|
value = self.get_field_value(field)
|
|
87
86
|
if value is None:
|
|
88
|
-
return f"The :attribute must not exceed
|
|
87
|
+
return f"The :attribute must not exceed :max"
|
|
89
88
|
|
|
90
89
|
# Check all possible file size attributes
|
|
91
90
|
file_attrs = ['content_length', 'size', 'fileno']
|
|
92
91
|
if any(hasattr(value, attr) for attr in file_attrs):
|
|
93
|
-
return f"File :attribute must not exceed
|
|
94
|
-
return f"The :attribute must not exceed
|
|
92
|
+
return f"File :attribute must not exceed :max bytes"
|
|
93
|
+
return f"The :attribute must not exceed :max"
|
|
95
94
|
|
|
96
95
|
class BetweenRule(Rule):
|
|
97
96
|
def validate(self, field: str, value: Any, params: List[str]) -> bool:
|
|
@@ -237,7 +236,7 @@ class SameRule(Rule):
|
|
|
237
236
|
return value == self.get_field_value(params[0])
|
|
238
237
|
|
|
239
238
|
def message(self, field: str, params: List[str]) -> str:
|
|
240
|
-
return f"The :attribute and
|
|
239
|
+
return f"The :attribute and :other must match."
|
|
241
240
|
|
|
242
241
|
class DifferentRule(Rule):
|
|
243
242
|
def validate(self, field: str, value: Any, params: List[str]) -> bool:
|
|
@@ -247,7 +246,7 @@ class DifferentRule(Rule):
|
|
|
247
246
|
return str(value) != self.get_field_value(params[0])
|
|
248
247
|
|
|
249
248
|
def message(self, field: str, params: List[str]) -> str:
|
|
250
|
-
return f"The :attribute and
|
|
249
|
+
return f"The :attribute and :other must be different."
|
|
251
250
|
|
|
252
251
|
class InRule(Rule):
|
|
253
252
|
def validate(self, field: str, value: Any, params: List[str]) -> bool:
|
|
@@ -105,7 +105,7 @@ class RuleErrorHandler:
|
|
|
105
105
|
'required_if', 'required_unless',
|
|
106
106
|
'exclude_if', 'exclude_unless',
|
|
107
107
|
'missing_if', 'missing_unless',
|
|
108
|
-
'present_if', 'present_unless'
|
|
108
|
+
'present_if', 'present_unless',
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
def _get_field_value_pairs(self) -> List[tuple]:
|
|
@@ -173,17 +173,10 @@ class RuleErrorHandler:
|
|
|
173
173
|
'required_with', 'required_with_all', 'required_without', 'required_without_all',
|
|
174
174
|
'prohibits', 'exclude_with', 'exclude_without',
|
|
175
175
|
'missing_with', 'missing_with_all',
|
|
176
|
-
'present_with', 'present_with_all'
|
|
176
|
+
'present_with', 'present_with_all', 'same', 'different'
|
|
177
177
|
}:
|
|
178
178
|
return self._current_params
|
|
179
179
|
|
|
180
|
-
# Single field rules
|
|
181
|
-
if rule in {
|
|
182
|
-
'required_if_accepted', 'required_if_declined',
|
|
183
|
-
'prohibited_if_accepted', 'prohibited_if_declined'
|
|
184
|
-
}:
|
|
185
|
-
return [self._current_params[0]] if self._current_params else []
|
|
186
|
-
|
|
187
180
|
return []
|
|
188
181
|
|
|
189
182
|
def _get_min_param(self) -> Optional[str]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|