data_structures¶
- class litestar.dto.data_structures.DTOData[source]¶
Bases:
Generic[T]DTO validated data and utility methods.
- create_instance(**kwargs: Any) T[source]¶
Create an instance of the DTO validated data.
- Parameters:
**kwargs¶ – Additional data to create the instance with. Takes precedence over DTO validated data.
- class litestar.dto.data_structures.DTOFieldDefinition[source]¶
Bases:
FieldDefinitionA model field representation for purposes of generating a DTO backend model type.
- __init__(raw: Any, annotation: Any, type_wrappers: tuple[type, ...], origin: Any, args: tuple[Any, ...], metadata: tuple[Any, ...], instantiable_origin: Any, safe_generic_origin: Any, inner_types: tuple[FieldDefinition, ...], default: Any, extra: dict[str, Any], kwarg_definition: KwargDefinition | DependencyKwarg | None, name: str, model_name: str, default_factory: Callable[[], Any] | None, dto_field: DTOField, passthrough_constraints: bool) None¶
- passthrough_constraints: bool¶
Pass constraints of the source annotation to be validated by the DTO backend
- classmethod from_field_definition(field_definition: FieldDefinition, model_name: str, default_factory: Callable[[], Any] | None, dto_field: DTOField, passthrough_constraints: bool = True) DTOFieldDefinition[source]¶
Create a
FieldDefinitionfrom aFieldDefinition.- Parameters:
field_definition¶ – A
FieldDefinitionto create aFieldDefinitionfrom.model_name¶ – The name of the model.
default_factory¶ – Default factory function, if any.
dto_field¶ – DTOField instance.
passthrough_constraints¶ – Pass constraints of the source annotation to be validated by the DTO backend
- Returns:
A
FieldDefinitioninstance.