deckhand.engine.document_validation module¶
-
class
deckhand.engine.document_validation.
BaseValidator
[source]¶ Bases:
object
Abstract base validator.
Sub-classes should override this to implement schema-specific document validation.
-
class
deckhand.engine.document_validation.
DataSchemaValidator
(data_schemas)[source]¶ Bases:
deckhand.engine.document_validation.GenericValidator
Validator for validating
DataSchema
documents.-
validate
(document, pre_validate=True)[source]¶ Validate
document
against built-inschema
-specific schemas.Does not apply to abstract documents.
Parameters: - document (DocumentDict) – Document to validate.
- pre_validate (bool) – Whether to pre-validate documents using built-in
schema validation. Skips over externally registered
DataSchema
documents to avoid false positives. Default is True.
Raises: RuntimeError – If the Deckhand schema itself is invalid.
Returns: Tuple of (error message, parent path for failing property) following schema validation failure.
Return type: Generator[Tuple[str, str]]
-
-
class
deckhand.engine.document_validation.
DocumentValidation
(documents, existing_data_schemas=None, pre_validate=True)[source]¶ Bases:
object
-
validate_all
()[source]¶ Validate that all documents are correctly formatted.
All concrete documents in the revision must successfully pass their JSON schema validations. The result of the validation is stored under the “deckhand-document-schema-validation” validation namespace for a document revision.
All abstract documents must themselves be sanity-checked.
Validation is broken up into 2 “main” stages:
- Validate that each document contains the basic bulding blocks
needed: i.e.
schema
andmetadata
using a “base” schema. Failing this validation is deemed a critical failure, resulting in an exception. - Execute
DataSchema
validations if applicable. Includes all built-inDataSchema
documents by default.
Returns: A list of validations (one for each document validated).
Return type: List[dict]
Raises: - errors.InvalidDocumentFormat – If the document failed schema validation and the failure is deemed critical.
- RuntimeError – If a Deckhand schema itself is invalid.
- Validate that each document contains the basic bulding blocks
needed: i.e.
-
-
class
deckhand.engine.document_validation.
DuplicateDocumentValidator
[source]¶ Bases:
deckhand.engine.document_validation.BaseValidator
Validator used for guarding against duplicate documents.
-
class
deckhand.engine.document_validation.
GenericValidator
[source]¶ Bases:
deckhand.engine.document_validation.BaseValidator
Validator used for validating all documents, regardless whether concrete or abstract, or what version its schema is.
-
base_schema
¶
-
validate
(document, **kwargs)[source]¶ Validate
document
against basic schema validation.Sanity-checks each document for mandatory keys like “metadata” and “schema”.
Applies even to abstract documents, as they must be consumed by concrete documents, so basic formatting is mandatory.
Failure to pass this check results in an error.
Parameters: document (dict) – Document to validate.
Raises: - RuntimeError – If the Deckhand schema itself is invalid.
- errors.InvalidDocumentFormat – If the document failed schema validation.
Returns: None
-
validate_metadata
(metadata)[source]¶ Validate
metadata
against the given schema.The
metadata
section of a Deckhand document describes a schema defining just themetadata
section. Use that declaration to choose a schema for validatingmetadata
.Parameters: metadata (dict) – Document metadata section to validate Returns: list of validation errors or empty list for success
-