Metadata-Version: 2.1
Name: pydantic-serializer
Version: 0.2.1
Summary: A decorator to serialize a string into a Pydantic model with error handling
Author: softmaxer
Author-email: sriram.vadlamani@proton.me
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: loguru (>=0.7.2,<0.8.0)
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
Description-Content-Type: text/markdown

# Pydantic deserializer

this is a simple decorator that can be used on functions that have a return type of `str`, To deserialize it into a given Pydantic Model.

## Usage:

For a function returning a string:

```py
def func_returning_str() -> str:
    return '{"sample": "json"}'
```

Let's say there's a Pydantic model like so:

```py
class SampleJson(BaseModel):
    sample: str
```

We can try and parse it with the decorator:

```py
from pydantic_serializer import deserialize

@deserialize(return_type=SampleJson)
def func_returning_str() -> str:
    return '{"sample": "json"}'
```

The function will return a `None` and log the error using `loguru` if there is an error.
If no error occurs, then you should get a return type of `SampleJson` in this case.

