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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datavalue
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: Librería de tipos de datos primitivos y complejos
5
5
  Author: Specter
6
6
  Requires-Python: >=3.10
@@ -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
- if data_objective not in self.possible_values:
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"The value is not in the possible values set: {data_objective} not in {self.possible_values}"
173
+ f"Value '{data_objective}' is not allowed by any of the provided validators."
157
174
  )
158
175
 
159
176
  # Validacion de expresion regular
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datavalue
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: Librería de tipos de datos primitivos y complejos
5
5
  Author: Specter
6
6
  Requires-Python: >=3.10
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "datavalue"
7
- version = "0.1.9"
7
+ version = "0.1.11"
8
8
  description = "Librería de tipos de datos primitivos y complejos"
9
9
  readme = "README.md"
10
10
  authors = [{ name="Specter" }]
File without changes
File without changes