data_structures#
- class litestar.dto.data_structures.DTOData#
Bases:
Generic
[T
]DTO validated data and utility methods.
- create_instance(**kwargs: Any) T #
Create an instance of the DTO validated data.
- Parameters:
**kwargs¶ – Additional data to create the instance with. Takes precedence over DTO validated data.
- update_instance(instance: T, **kwargs: Any) T #
Update an instance with the DTO validated data.
- as_builtins() Any #
Return the DTO validated data as builtins.
- class litestar.dto.data_structures.DTOFieldDefinition#
Bases:
FieldDefinition
A 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 #
Create a
FieldDefinition
from aFieldDefinition
.- Parameters:
field_definition¶ – A
FieldDefinition
to create aFieldDefinition
from.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
FieldDefinition
instance.