type_bridge.validation¶
validation
¶
Validation utilities for TypeBridge.
This module provides validation functions to ensure type names, attribute names, and role names don't conflict with TypeQL reserved words/keywords.
ValidationError
¶
Bases: ValueError
Base class for validation errors in TypeBridge.
ReservedWordError
¶
Bases: ValidationError
Raised when a type name conflicts with a TypeQL reserved word.
This error is raised when attempting to use a TypeQL keyword as a: - Entity type name - Relation type name - Attribute type name - Role name
Initialize ReservedWordError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
word
|
str
|
The reserved word that was used |
required |
context
|
Literal['entity', 'relation', 'attribute', 'role']
|
What kind of name was being validated |
required |
suggestion
|
str | None
|
Optional suggested alternative name |
None
|
Source code in type_bridge/validation.py
validate_type_name
¶
Validate that a type name doesn't conflict with TypeQL reserved words.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The type name to validate |
required |
context
|
Literal['entity', 'relation', 'attribute', 'role']
|
What kind of name is being validated |
required |
Raises:
| Type | Description |
|---|---|
ReservedWordError
|
If the name is a TypeQL reserved word |
ValidationError
|
If the name is invalid for other reasons |
Source code in type_bridge/validation.py
validate_query_against_schema
¶
Validate parsed query clauses against a TypeSchema.
This performs semantic validation: ownership checks, role validation, value type compatibility, abstract type instantiation, and cardinality hints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clauses
|
list[dict[str, Any]]
|
Parsed clauses (from |
required |
schema
|
Any
|
A |
required |
strict
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
dict[str, Any]
|
Each error dict has |
Source code in type_bridge/validation.py
validate_entity_data
¶
Validate entity data against custom validation rules.
Uses the Rust ValidationEngine to evaluate rules defined in the
portable JSON DSL (see :class:~type_bridge.rules.RuleBuilder).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_data
|
dict[str, Any]
|
Dict with |
required |
rules_json
|
str
|
JSON string of validation rules. |
required |
schema
|
Any
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |