cyclonedx.validation

Submodules

Package Contents

Classes

ValidationError

Validation failed with this specific error.

SchemabasedValidator

Schema-based Validator protocol

BaseSchemabasedValidator

Base Schema-based Validator

Functions

make_schemabased_validator(…)

get the default Schema-based Validator for a certain :class:OutputFormat.

class cyclonedx.validation.ValidationError(data: Any)

Validation failed with this specific error.

Use data to access the content.

data: Any
class cyclonedx.validation.SchemabasedValidator

Bases: Protocol

Schema-based Validator protocol

validate_str(data: str) ValidationError | None

Validate a string

Parameters:

data – the data string to validate

Returns:

validation error

Retval None:

if data is valid

Retval ValidationError:

if data is invalid

class cyclonedx.validation.BaseSchemabasedValidator(schema_version: cyclonedx.schema.SchemaVersion)

Bases: abc.ABC, SchemabasedValidator

Base Schema-based Validator

property schema_version: cyclonedx.schema.SchemaVersion

get the schema version.

abstract property output_format: cyclonedx.schema.OutputFormat

get the format.

validate_str(data: str) ValidationError | None

Validate a string

Parameters:

data – the data string to validate

Returns:

validation error

Retval None:

if data is valid

Retval ValidationError:

if data is invalid

cyclonedx.validation.make_schemabased_validator(output_format: Literal[cyclonedx.schema.OutputFormat.JSON], schema_version: cyclonedx.schema.SchemaVersion) json.JsonValidator
cyclonedx.validation.make_schemabased_validator(output_format: Literal[cyclonedx.schema.OutputFormat.XML], schema_version: cyclonedx.schema.SchemaVersion) xml.XmlValidator
cyclonedx.validation.make_schemabased_validator(output_format: cyclonedx.schema.OutputFormat, schema_version: cyclonedx.schema.SchemaVersion) json.JsonValidator | xml.XmlValidator

get the default Schema-based Validator for a certain :class:OutputFormat.

Raises error when no instance could be made.