Skip to main content

is_union_of_base_models

Check if field type is a Union where all members are BaseModel subclasses.

def is_union_of_base_models(
field_type: Any
) - > bool

Check if field type is a Union where all members are BaseModel subclasses.

Parameters

NameTypeDescription
field_typeAnyThe type hint or class to evaluate for Union membership and BaseModel compatibility

Returns

TypeDescription
boolTrue if the type is a Union and every member of that Union is a subclass of Pydantic's BaseModel, otherwise False