SerField
This class represents a field configuration for serialization, mapping a specific key to its corresponding serializer and metadata. It manages field-level settings such as aliases, requirement status, and conditional exclusion logic to determine how data should be processed during the serialization phase.
Attributes
| Attribute | Type | Description |
|---|---|---|
| key | PyBackedStr | The original attribute name on the Python object used as the source for serialization. |
| alias | Option< PyBackedStr > | An alternative name used for the field in the serialized output instead of the original key. |
| serializer | Option< Arc< CombinedSerializer > > | The specific serialization logic applied to this field; if set to None, the field is excluded from output. |
| required | bool | A boolean flag indicating whether the field must be present during the serialization process. |
| serialize_by_alias | Option< bool > | Determines whether to use the defined alias instead of the key when generating the serialized representation. |
| serialization_exclude_if | Option< Py< PyAny > > | A Python callable or condition that determines if the field should be omitted from serialization based on its value. |
Constructor
Signature
def SerField(
key: PyBackedStr,
alias: Option< PyBackedStr >,
serializer: Option< Arc< CombinedSerializer > >,
required: bool,
serialize_by_alias: Option< bool >,
serialization_exclude_if: Option< Py< PyAny > >
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| key | PyBackedStr | The primary key name for the field. |
| alias | Option< PyBackedStr > | An optional alternative name for the field during serialization. |
| serializer | Option< Arc< CombinedSerializer > > | The serializer to use for this field; if None, the field is excluded. |
| required | bool | Indicates if the field is mandatory. |
| serialize_by_alias | Option< bool > | Determines if the alias should be used for serialization. |
| serialization_exclude_if | Option< Py< PyAny > > | A condition or value that determines if the field should be excluded from serialization. |
Signature
def SerField(
key: PyBackedStr,
alias: Option< PyBackedStr >,
serializer: Option< Arc< CombinedSerializer > >,
required: bool,
serialize_by_alias: Option< bool >,
serialization_exclude_if: Option< Py< PyAny > >
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| key | PyBackedStr | The primary attribute name of the field as it exists on the Python object. |
| alias | Option< PyBackedStr > | An alternative name used for the field during serialization, often for compatibility with external APIs. |
| serializer | Option< Arc< CombinedSerializer > > | The specific serialization logic to apply; if None, the field is excluded from the output. |
| required | bool | Indicates whether the field must be present during the serialization process. |
| serialize_by_alias | Option< bool > | Determines if the alias should be used instead of the key when generating the serialized output. |
| serialization_exclude_if | Option< Py< PyAny > > | A Python callable or condition used to dynamically determine if the field should be omitted from the output based on its value. |