datavalue 0.1.9__tar.gz → 0.1.11__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.
- {datavalue-0.1.9 → datavalue-0.1.11}/PKG-INFO +1 -1
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue/classes/primitive_data.py +19 -2
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue.egg-info/PKG-INFO +1 -1
- {datavalue-0.1.9 → datavalue-0.1.11}/pyproject.toml +1 -1
- {datavalue-0.1.9 → datavalue-0.1.11}/README.md +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue/__init__.py +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue/classes/__init__.py +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue/classes/complex_data.py +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue/exceptions/__init__.py +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue.egg-info/SOURCES.txt +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue.egg-info/dependency_links.txt +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/datavalue.egg-info/top_level.txt +0 -0
- {datavalue-0.1.9 → datavalue-0.1.11}/setup.cfg +0 -0
|
@@ -29,6 +29,21 @@ class PrimitiveData:
|
|
|
29
29
|
self.validate()
|
|
30
30
|
|
|
31
31
|
# Private methods
|
|
32
|
+
def _is_match(self, element: Any, schema: Any) -> bool:
|
|
33
|
+
if isinstance(schema, PrimitiveData):
|
|
34
|
+
try:
|
|
35
|
+
# Si el validador hijo no lanza excepción, el match es exitoso
|
|
36
|
+
return schema.validate(element)
|
|
37
|
+
except (exceptions.DataValueException, ValueError, TypeError):
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
# 2. Caso: El esquema es un tipo de dato (clase como str, int)
|
|
41
|
+
if isinstance(schema, type):
|
|
42
|
+
return isinstance(element, schema)
|
|
43
|
+
|
|
44
|
+
# 3. Caso: El esquema es un valor literal
|
|
45
|
+
return element == schema
|
|
46
|
+
|
|
32
47
|
def __get_length(self, data: Optional[Any] = None) -> Optional[int]:
|
|
33
48
|
if data is None:
|
|
34
49
|
data_objective = self.value
|
|
@@ -150,10 +165,12 @@ class PrimitiveData:
|
|
|
150
165
|
raise exceptions.PossibleValueException(
|
|
151
166
|
f"The boolean value has to be True or False: {data_objective} != True/False"
|
|
152
167
|
)
|
|
168
|
+
|
|
153
169
|
if self.possible_values is not None:
|
|
154
|
-
|
|
170
|
+
# Implementación de any() con _is_match para soportar la composición de tipos
|
|
171
|
+
if not any(self._is_match(data_objective, validator) for validator in self.possible_values):
|
|
155
172
|
raise exceptions.PossibleValueException(
|
|
156
|
-
f"
|
|
173
|
+
f"Value '{data_objective}' is not allowed by any of the provided validators."
|
|
157
174
|
)
|
|
158
175
|
|
|
159
176
|
# Validacion de expresion regular
|
|
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
|