cyclonedx.validation
====================

.. py:module:: cyclonedx.validation


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/cyclonedx/validation/json/index
   /autoapi/cyclonedx/validation/model/index
   /autoapi/cyclonedx/validation/xml/index


Classes
-------

.. autoapisummary::

   cyclonedx.validation.ValidationError
   cyclonedx.validation.SchemabasedValidator
   cyclonedx.validation.BaseSchemabasedValidator


Functions
---------

.. autoapisummary::

   cyclonedx.validation.make_schemabased_validator


Package Contents
----------------

.. py:class:: ValidationError(data: Any)

   Validation failed with this specific error.

   Use :attr:`~data` to access the content.


   .. py:attribute:: data
      :type:  Any

      Raw error data from one of the underlying validation methods.



.. py:class:: SchemabasedValidator

   Bases: :py:obj:`Protocol`


   Schema-based Validator protocol


   .. py:method:: validate_str(data: str, *, all_errors: Literal[False] = ...) -> Optional[ValidationError]
                  validate_str(data: str, *, all_errors: Literal[True]) -> Optional[collections.abc.Iterable[ValidationError]]

      Validate a string

      :param data: the data string to validate
      :param all_errors: whether to return all errors or only (any)one - if any
      :return: 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``



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

   Bases: :py:obj:`abc.ABC`, :py:obj:`SchemabasedValidator`


   Base Schema-based Validator


   .. py:property:: schema_version
      :type: cyclonedx.schema.SchemaVersion


      Get the schema version.



   .. py:property:: output_format
      :type: cyclonedx.schema.OutputFormat

      :abstractmethod:


      Get the format.



   .. py:method:: validate_str(data: str, *, all_errors: Literal[False] = ...) -> Optional[ValidationError]
                  validate_str(data: str, *, all_errors: Literal[True]) -> Optional[collections.abc.Iterable[ValidationError]]

      Validate a string

      :param data: the data string to validate
      :param all_errors: whether to return all errors or only (any)one - if any
      :return: 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``



.. py:function:: make_schemabased_validator(output_format: Literal[cyclonedx.schema.OutputFormat.JSON], schema_version: cyclonedx.schema.SchemaVersion) -> json.JsonValidator
                 make_schemabased_validator(output_format: Literal[cyclonedx.schema.OutputFormat.XML], schema_version: cyclonedx.schema.SchemaVersion) -> xml.XmlValidator
                 make_schemabased_validator(output_format: cyclonedx.schema.OutputFormat, schema_version: cyclonedx.schema.SchemaVersion) -> Union[json.JsonValidator, xml.XmlValidator]

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

   Raises error when no instance could be made.


