Skip to content

SHACL commands

kurra.cli.commands.shacl

validate_command(data: Annotated[list[Path], typer.Argument(help='The file, files or directory of RDF files to be validated')], shacl: Annotated[str, typer.Option(--shacl, -s, callback=_parse_shacl, help='The file, directory of files, IRI of or the kurra ID for the SHACL graph to validate with')], hide_warnings: Annotated[bool, typer.Option(--hide - warnings, -hw, help='Hides Shapes results of Warning and Info')] = False) -> None

Validate a given file or directory of files using a given SHACL file or directory of files

Source code in kurra/cli/commands/shacl.py
@app.command(
    name="validate",
    help="Validate a given file or directory of RDF files using a given SHACL file or directory of files",
)
def validate_command(
    data: Annotated[
        list[Path],
        typer.Argument(
            help="The file, files or directory of RDF files to be validated"
        ),
    ],
    shacl: Annotated[
        str,
        typer.Option(
            "--shacl",
            "-s",
            callback=_parse_shacl,
            help="The file, directory of files, IRI of or the kurra ID for the SHACL graph to validate with",
        ),
    ],
    hide_warnings: Annotated[
        bool,
        typer.Option(
            "--hide-warnings", "-hw", help="Hides Shapes results of Warning and Info"
        ),
    ] = False,
) -> None:
    """Validate a given file or directory of files using a given SHACL file or directory of files"""
    valid, g, txt = validate(data, shacl, hide_warnings=hide_warnings)

    if valid:
        console.print("The data is valid")
    else:
        console.print("The data is NOT valid")
        console.print("The errors are:")
        console.print(format_shacl_graph_as_rich_table(g))