diff --git a/pyproject.toml b/pyproject.toml index 627636c..54a5468 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "retrack" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.2" description = "A business rules engine" authors = ["Gabriel Guarisa ", "Nathalia Trotte "] license = "MIT" diff --git a/retrack/engine/request_manager.py b/retrack/engine/request_manager.py index a4b484f..7facb7f 100644 --- a/retrack/engine/request_manager.py +++ b/retrack/engine/request_manager.py @@ -71,7 +71,7 @@ def __create_model( fields = {} for input_field in self.inputs: fields[input_field.data.name] = ( - str, + typing.Annotated[str, pydantic.BeforeValidator(str)], pydantic.Field( default=Ellipsis if input_field.data.default is None diff --git a/tests/test_engine/test_request_manager.py b/tests/test_engine/test_request_manager.py index 34c4413..3d30ac3 100644 --- a/tests/test_engine/test_request_manager.py +++ b/tests/test_engine/test_request_manager.py @@ -48,3 +48,10 @@ def test_validate_payload_with_valid_payload(valid_input_dict_before_validation) assert isinstance(payload, pydantic.BaseModel) result = rm.validate(pd.DataFrame([{"example": "test"}])) assert isinstance(result, pd.DataFrame) + + +def test_validate_dict_with_model(valid_input_dict_before_validation): + rm = RequestManager([Input(**valid_input_dict_before_validation)]) + + assert issubclass(rm.model, pydantic.BaseModel) + assert rm.model.model_validate({"example": 1111}) == rm.model(example="1111")