Skip to content

validate_schema.py§

validate_schema(state) §

Validate the generated TTL output against the BrickSchema.

Parameters:

Name Type Description Default
state State

The current state containing the TTL output and validation parameters.

required

Returns:

Name Type Description
dict Dict[str, Any]

A dictionary containing the validation status and report.

Source code in brickllm/nodes/validate_schema.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def validate_schema(state) -> Dict[str, Any]:
    """
    Validate the generated TTL output against the BrickSchema.

    Args:
        state (State): The current state containing the TTL output and validation parameters.

    Returns:
        dict: A dictionary containing the validation status and report.
    """
    custom_logger.eurac("✅ Validating TTL schema")

    ttl_output = state.get("ttl_output", None)
    max_iter = state.get("validation_max_iter", 2)

    max_iter -= 1

    if ttl_output is None:
        return {
            "is_valid": False,
            "validation_report": "Empty TTL output.",
            "validation_max_iter": max_iter,
        }

    is_valid, report = validate_ttl(ttl_output)

    return {
        "is_valid": is_valid,
        "validation_report": report,
        "validation_max_iter": max_iter,
    }