Component Config Model
Base model for modality transformer configuration schemas.
ComponentConfigModel(**data)
Bases: BaseModel
Configuration model that reports invalid options as a component configuration error.
Construction and every pydantic validation entry point (model_validate, model_validate_json, and
model_validate_strings) raise ComponentConfigError instead of pydantic's ValidationError. The __init__
override is marked as pydantic's base init, so pydantic validation does not call it and nest the error inside a
ValidationError.
Attributes:
| Name | Type | Description |
|---|---|---|
_component |
ClassVar[str]
|
Component name used in the error message. |
_subject |
ClassVar[str]
|
Description of the validated options used in the error message. |
_default_parameter |
ClassVar[str]
|
Parameter named when the failing field cannot be determined. |
_operation |
ClassVar[str]
|
Diagnostic operation recorded in the error's debug_info. |
Initialize the configuration, reporting invalid options as a component configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
Configuration options. |
{}
|
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If an option is unknown or has an invalid value. |
model_validate(obj, **kwargs)
classmethod
Validate an object, reporting invalid options as a component configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to validate. |
required |
**kwargs
|
Any
|
Keyword arguments forwarded to pydantic's model_validate. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The validated configuration. |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If an option is unknown or has an invalid value. |
model_validate_json(json_data, **kwargs)
classmethod
Validate a JSON document, reporting invalid options as a component configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
str | bytes | bytearray
|
The JSON document to validate. |
required |
**kwargs
|
Any
|
Keyword arguments forwarded to pydantic's model_validate_json. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The validated configuration. |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If the document is not valid JSON, or an option is unknown or has an invalid value. |
model_validate_strings(obj, **kwargs)
classmethod
Validate an object of string values, reporting invalid options as a component configuration error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object of string values to validate. |
required |
**kwargs
|
Any
|
Keyword arguments forwarded to pydantic's model_validate_strings. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
The validated configuration. |
Raises:
| Type | Description |
|---|---|
ComponentConfigError
|
If an option is unknown or has an invalid value. |