Explorar el Código

fix: validator

Sam Jaffe hace 1 mes
padre
commit
de144f203e
Se han modificado 2 ficheros con 7 adiciones y 4 borrados
  1. 1 1
      src/cipy/action.py
  2. 6 3
      src/cipy/common.py

+ 1 - 1
src/cipy/action.py

@@ -74,7 +74,7 @@ class Composite(Action):
 
     @final
     def run(self, context: Context) -> Status:
-        status = Status.SKIPPED
+        status = Status.SUCCESS
 
         with context.extend(steps=self._results) as outctx:
             for step in self.steps:

+ 6 - 3
src/cipy/common.py

@@ -41,9 +41,12 @@ class Ref(str):
     @classmethod
     # pylint: disable=unused-argument
     def __get_pydantic_core_schema__(cls, source, handler) -> core_schema.CoreSchema:
-        return core_schema.general_plain_validator_function(
-            lambda s: s and all(t for t in s.split("."))
-        )
+
+        def validate(s, _):
+            if s and all(t for t in s.split(".")):
+                return s
+            raise ValueError("References must be of the form A.B.C etc.")
+        return core_schema.general_plain_validator_function(validate)
 
 
 @dataclasses.dataclass