ConfigDict
A TypedDict for configuring Pydantic behaviour.
Attributes
| Attribute | Type | Description |
|---|---|---|
| title | `str | None` = None |
| model_title_generator | `Callable[[type], str] | None` = None |
| field_title_generator | `Callable[[str, FieldInfo | ComputedFieldInfo], str] |
| str_to_lower | bool = False | Whether to convert all characters to lowercase for str types. Defaults to False. |
| str_to_upper | bool = False | Whether to convert all characters to uppercase for str types. Defaults to False. |
| str_strip_whitespace | bool | Whether to strip leading and trailing whitespace for str types. |
| str_min_length | int = None | The minimum length for str types. Defaults to None. |
| str_max_length | `int | None` = None |
| extra | `ExtraValues | None` = 'ignore' |
| frozen | bool = False | Whether models are faux-immutable, i.e. whether __setattr__ is allowed, and also generates a __hash__() method for the model. |
| populate_by_name | bool = False | Whether an aliased field may be populated by its name as given by the model attribute, as well as the alias. Defaults to False. |
| use_enum_values | bool = False | Whether to populate models with the [value][enum.Enum.value] property of enums, rather than the raw enum. Defaults to False. |
| validate_assignment | bool = False | Whether to validate the data when the model is changed. Defaults to False. |
| arbitrary_types_allowed | bool = False | Whether arbitrary types are allowed for field types. Defaults to False. |
| from_attributes | bool | Whether to build models and look up discriminators of tagged unions using python object attributes. |
| loc_by_alias | bool = True | Whether to use the actual key provided in the data (e.g. alias) for error locs rather than the field's name. Defaults to True. |
| alias_generator | `Callable[[str], str] | AliasGenerator |
| ignored_types | tuple[type, ...] = () | A tuple of types that may occur as values of class attributes without annotations. Defaults to (). |
| allow_inf_nan | bool = True | Whether to allow infinity (+inf an -inf) and NaN values to float and decimal fields. Defaults to True. |
| json_schema_extra | `JsonDict | JsonSchemaExtraCallable |
| json_encoders | `dict[type[object], JsonEncoder] | None` = None |
| strict | bool | Whether strict validation is applied to all fields on the model. |
| revalidate_instances | Literal['always', 'never', 'subclass-instances'] = 'never' | When and how to revalidate models and dataclasses during validation. Defaults to 'never'. |
| ser_json_timedelta | Literal['iso8601', 'float'] = 'iso8601' | The format of JSON serialized timedeltas. Accepts the string values of 'iso8601' and 'float'. Defaults to 'iso8601'. |
| ser_json_temporal | Literal['iso8601', 'seconds', 'milliseconds'] = 'iso8601' | The format of JSON serialized temporal types from the [datetime][] module. Defaults to 'iso8601'. |
| val_temporal_unit | Literal['seconds', 'milliseconds', 'infer'] = 'infer' | The unit to assume for validating numeric input for datetime-like types ([datetime.datetime][] and [datetime.date][]). Defaults to 'infer'. |
| ser_json_bytes | Literal['utf8', 'base64', 'hex'] = 'utf8' | The encoding of JSON serialized bytes. Defaults to 'utf8'. |
| val_json_bytes | Literal['utf8', 'base64', 'hex'] = 'utf8' | The encoding of JSON serialized bytes to decode. Defaults to 'utf8'. |
| ser_json_inf_nan | Literal['null', 'constants', 'strings'] = 'null' | The encoding of JSON serialized infinity and NaN float values. Defaults to 'null'. |
| validate_default | bool = False | Whether to validate default values during validation. Defaults to False. |
| validate_return | bool = False | Whether to validate the return value from call validators. Defaults to False. |
| protected_namespaces | `tuple[str | Pattern[str], ...]` = ('model_validate', 'model_dump') |
| hide_input_in_errors | bool = False | Whether to hide inputs when printing errors. Defaults to False. |
| defer_build | bool = False | Whether to defer model validator and serializer construction until the first model validation. Defaults to False. |
| plugin_settings | `dict[str, object] | None` = None |
| schema_generator | `type[_GenerateSchema] | None` |
| json_schema_serialization_defaults_required | bool = False | Whether fields with default values should be marked as required in the serialization schema. Defaults to False. |
| json_schema_mode_override | Literal['validation', 'serialization', None] = None | If not None, the specified mode will be used to generate the JSON schema regardless of what mode was passed to the function call. Defaults to None. |
| coerce_numbers_to_str | bool = False | If True, enables automatic coercion of any Number type to str in "lax" (non-strict) mode. Defaults to False. |
| regex_engine | Literal['rust-regex', 'python-re'] = 'rust-regex' | The regex engine to be used for pattern validation. Defaults to 'rust-regex'. |
| validation_error_cause | bool = False | If True, Python exceptions that were part of a validation failure will be shown as an exception group as a cause. Defaults to False. |
| use_attribute_docstrings | bool = False | Whether docstrings of attributes (bare string literals immediately following the attribute declaration) should be used for field descriptions. Defaults to False. |
| cache_strings | `bool | Literal['all', 'keys', 'none']` = True |
| validate_by_alias | bool = True | Whether an aliased field may be populated by its alias. Defaults to True. |
| validate_by_name | bool = False | Whether an aliased field may be populated by its name as given by the model attribute. Defaults to False. |
| serialize_by_alias | bool = False | Whether an aliased field should be serialized by its alias. Defaults to False. |
| url_preserve_empty_path | bool = False | Whether to preserve empty URL paths when validating values for a URL type. Defaults to False. |
| polymorphic_serialization | bool = False | Whether to use polymorphic serialization for subclasses of the model or Pydantic dataclass. Defaults to False. |
Constructor
Signature
def ConfigDict()
Signature
def ConfigDict()