Skip to content

Conversation

@exorevan
Copy link

Implement a check to ensure the sequence length is greater than 0 before adding the field to the embedded dictionary.

For example: if field value is '' then it goes to embedded dict from the model

…ore adding the field to the embedded dictionary
@ELC
Copy link
Collaborator

ELC commented Mar 12, 2025

Could you provide a minimal example where this is a problem?

@exorevan
Copy link
Author

exorevan commented Mar 13, 2025

Of course:

>>> import fastapi_hypermodel
>>> class Process(fastapi_hypermodel.HALHyperModel):
...     number: int
...     message: str | None
... 
>>> process_dict = {"number": 0, "message": ""}
>>> process_hal = Process(**process_dict)
>>> process_hal
Process(links=None, embedded={'message': ''}, number=0)

@jtc42
Copy link
Owner

jtc42 commented Apr 6, 2025

@ELC are you happy for this one to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants