cdm_data_loaders.converters.core.guards ¶
JSON Schema input guards and shared reader configuration validators.
validate_max_recursion_depth ¶
Validate that depth is a positive integer (excluding booleans).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int
|
Recursion depth limit to validate. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in src/cdm_data_loaders/converters/core/guards.py
require_schema_keyword ¶
require_schema_keyword(
schema: dict[str, Any],
error: type[ConversionError],
*,
converter_name: str = "Converter"
) -> None
Reject a schema with no top-level '$schema' keyword.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
the input JSON Schema document |
required |
error
|
type[ConversionError]
|
the direction-specific error class to raise |
required |
converter_name
|
str
|
converter name used in the diagnostic |
'Converter'
|
Raises:
| Type | Description |
|---|---|
ConversionError
|
if the schema has no '$schema' keyword |
Source code in src/cdm_data_loaders/converters/core/guards.py
require_object_root ¶
Reject a schema whose declared root type isn't literally 'object' or absent.
This is intentionally stricter than readers.json_schema.JsonSchemaReader,
which also accepts a list-form root type (e.g. ["object", "null"]) when
used directly. Facade converters call this guard first, so a nullable
root type is only reachable through direct reader use, not through
convert().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
the input JSON Schema document |
required |
error
|
type[ConversionError]
|
the direction-specific error class to raise |
required |
target
|
str
|
what the root maps to in the error message (e.g. 'a dlt table') |
required |
Raises:
| Type | Description |
|---|---|
ConversionError
|
if the root 'type' is declared and is not 'object' |
Source code in src/cdm_data_loaders/converters/core/guards.py
reject_unresolved_references ¶
reject_unresolved_references(
schema: dict[str, Any],
error: type[ConversionError],
*,
converter_name: str = "Converter",
dereference_function: str = "dereference_schema"
) -> None
Guard against un-dereferenced schemas reaching the type-dispatch logic.
$ref (including references into external JSON Schema documents) and allOf
resolution are intentionally not performed here; run
dereference_schema() first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict[str, Any]
|
the schema fragment to check for unresolved '$ref'/'allOf' |
required |
error
|
type[ConversionError]
|
the direction-specific error class to raise |
required |
converter_name
|
str
|
converter name used in the diagnostic |
'Converter'
|
dereference_function
|
str
|
qualified dereferencing function name |
'dereference_schema'
|
Raises:
| Type | Description |
|---|---|
ConversionError
|
if the schema still contains '$ref' or 'allOf' |