ModelFieldsSchema
This class defines the schema for model fields within a TypedDict structure, specifically for use in data validation and serialization frameworks. It maps field names to their respective definitions while supporting additional configurations such as computed fields, strict mode, and attribute-based loading. The schema also provides hooks for handling extra behaviors, metadata, and custom serialization logic.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | Literal['model-fields'] | A fixed literal identifier used to distinguish this schema as a model-fields type. |
| fields | dict[str, [ModelField](modelfield.md?sid=pydantic_core_core_schema_modelfield)] | A mapping of field names to their respective ModelField definitions which define the structure of the model. |
| model_name | string | The name of the model class used for identification and error messaging. |
| computed_fields | list[[ComputedField](computedfield.md?sid=pydantic_core_core_schema_computedfield)] | A list of fields that are calculated from other attributes rather than being directly assigned. |
| strict | boolean | A boolean flag that determines whether to enforce strict validation rules for the model fields. |
| extras_schema | CoreSchema | The CoreSchema used to validate any extra fields provided that are not explicitly defined in the fields mapping. |
| extras_keys_schema | CoreSchema | The CoreSchema used to validate the keys of any extra fields provided to the model. |
| extra_behavior | ExtraBehavior | Defines how the model should handle fields that are not defined in the schema, such as allowing, forbidding, or ignoring them. |
| from_attributes | boolean | Whether to allow extracting values from object attributes during validation instead of just mapping-like objects. |
| ref | string | A unique string reference used for recursive schemas or to identify this specific schema in a larger context. |
| metadata | dict[str, Any] | A dictionary of arbitrary metadata used to store additional information for third-party extensions or custom logic. |
| serialization | SerSchema | The serialization schema used to define how the model should be converted into a serializable format. |