cyclonedx.validation.json

Classes

JsonValidationError

Validation failed with this specific error.

JsonValidator

Validator for CycloneDX documents in JSON format.

JsonStrictValidator

Strict validator for CycloneDX documents in JSON format.

Module Contents

class cyclonedx.validation.json.JsonValidationError(data: Any)

Bases: cyclonedx.validation.ValidationError

Validation failed with this specific error.

Use data to access the content.

data: Any

Raw error data from one of the underlying validation methods.

class cyclonedx.validation.json.JsonValidator(schema_version: cyclonedx.schema.SchemaVersion)

Bases: _BaseJsonValidator, cyclonedx.validation.BaseSchemabasedValidator, cyclonedx.validation.SchemabasedValidator

Validator for CycloneDX documents in JSON format.

property output_format: Literal[cyclonedx.schema.OutputFormat.JSON]

Get the format.

validate_str(data: str, *, all_errors: Literal[False] = ...) JsonValidationError | None
validate_str(data: str, *, all_errors: Literal[True]) collections.abc.Iterable[JsonValidationError] | None

Validate a string

Parameters:
  • data – the data string to validate

  • all_errors – whether to return all errors or only (any)one - if any

Returns:

validation error

Retval None:

if data is valid

Retval ValidationError:

if data is invalid and all_errors is False

Retval Iterable[ValidationError]:

if data is invalid and all_errors is True

property schema_version: cyclonedx.schema.SchemaVersion

Get the schema version.

class cyclonedx.validation.json.JsonStrictValidator(schema_version: cyclonedx.schema.SchemaVersion)

Bases: _BaseJsonValidator, cyclonedx.validation.BaseSchemabasedValidator, cyclonedx.validation.SchemabasedValidator

Strict validator for CycloneDX documents in JSON format.

In contrast to JsonValidator, the document must not have additional or unknown JSON properties.

property output_format: Literal[cyclonedx.schema.OutputFormat.JSON]

Get the format.

validate_str(data: str, *, all_errors: Literal[False] = ...) JsonValidationError | None
validate_str(data: str, *, all_errors: Literal[True]) collections.abc.Iterable[JsonValidationError] | None

Validate a string

Parameters:
  • data – the data string to validate

  • all_errors – whether to return all errors or only (any)one - if any

Returns:

validation error

Retval None:

if data is valid

Retval ValidationError:

if data is invalid and all_errors is False

Retval Iterable[ValidationError]:

if data is invalid and all_errors is True

property schema_version: cyclonedx.schema.SchemaVersion

Get the schema version.