Skip to content

Add context casting functionality #161

@vstolin

Description

@vstolin

Please consider functionality that allows to validate if context A can be cast into context B at model definition time even when there is no direct inheritance between A and B. Consider the following example:

from ccflow import ContextBase

class A(ContextBase):
   foo: str = "x"
class B(ContextBase):
   foo: str = "x"

B.model_validate(A())

This is fully supported use case, but the limitation is that it requires an instance of A(). It would be helpful if we could do something like:

B.context_validate(A)

which returns True if context A can be cast to context B or False otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions