dal.validation package

Submodules

dal.validation.constants module

Validation constants

dal.validation.schema module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Moawiya Mograbi (moawiya@mov.ai) - 2022

class dal.validation.schema.Schema(schema_path: Path)

Bases: object

validate(data: dict) ValidationResult

Validate data against the schema.

Parameters:

data (dict) – The data to be validated.

Returns:

Validation results.

Return type:

ValidationResult

class dal.validation.schema.ValidationResult(*args, **kwargs)

Bases: dict

message: str
status: bool

dal.validation.template module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Alexandre Pires (alexandre.pires@mov.ai) - 2020

class dal.validation.template.Template(**kwargs)

Bases: object

Loads a config file from json based on a given schema

Example

protocol_config = {

“name”: str, “parameters”: dict,

}

callback_config = {

“name”: str, “libs”: dict, “file”: str

}

port_config = {

“name”: str, “direction”: str, “protocol”: protocol_config, “callback”: callback_config

}

node_config = {

“logfile”: str, “name”: str, “parameters”: dict, “ports”: [port_config]

}

c = Template.load(“node.json”, node_config, “./tests/configs”)

static load(uri: str, config: dict)

Loads a configuration file, validate against config schema returns a Template object

static load_dict(values: dict, config: dict)

Creates a template from a dictionary

dal.validation.validator module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Moawiya Mograbi (moawiya@mov.ai) - 2022

class dal.validation.validator.JsonValidator(*args, **kwargs)

Bases: object

Validator responsible to load schema json files and validate files according to it’s type.

VERSION = '2.4'
validate(scope: str, data: dict)

Validate the content against the schema of the given scope.

Parameters:
  • scope (str) – The type of the schema to validate against.

  • data (dict) – The data to validate.

Raises:
  • SchemaTypeNotKnown – If the scope is not known to the validator.

  • ValueError – If the data does not conform to the schema.

class dal.validation.validator.POFileValidator

Bases: object

Confirm the PO file has a valid format

static validate(scope: str, data: dict)

Validate the content against the schema of the given scope.

Parameters:
  • scope (str) – The type of the schema to validate against.

  • data (dict) – The data to validate.

Raises:
  • SchemaTypeNotKnown – If the scope is not known to the validator.

  • ValueError – If the data does not conform to the schema.

class dal.validation.validator.TranslationValidator

Bases: object

static validate(scope: str, data: dict)

Validate the content against the schema of the given scope.

Parameters:
  • scope (str) – The type of the schema to validate against.

  • data (dict) – The data to validate.

Raises:
  • SchemaTypeNotKnown – If the scope is not known to the validator.

  • ValueError – If the data does not conform to the schema.

class dal.validation.validator.Validator(*args, **kwargs)

Bases: Protocol

Protocol for validators that validate data against a schema.

static validate(scope: str, data: dict) None

Validate the content against the schema of the given scope.

Parameters:
  • scope (str) – The type of the schema to validate against.

  • data (dict) – The data to validate.

Raises:
  • SchemaTypeNotKnown – If the scope is not known to the validator.

  • ValueError – If the data does not conform to the schema.

Module contents

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Moawiya Mograbi (moawiya@mov.ai) - 2022

class dal.validation.JsonValidator(*args, **kwargs)

Bases: object

Validator responsible to load schema json files and validate files according to it’s type.

VERSION = '2.4'
schema_types: Dict[str, Schema]
validate(scope: str, data: dict)

Validate the content against the schema of the given scope.

Parameters:
  • scope (str) – The type of the schema to validate against.

  • data (dict) – The data to validate.

Raises:
  • SchemaTypeNotKnown – If the scope is not known to the validator.

  • ValueError – If the data does not conform to the schema.

class dal.validation.Schema(schema_path: Path)

Bases: object

validate(data: dict) ValidationResult

Validate data against the schema.

Parameters:

data (dict) – The data to be validated.

Returns:

Validation results.

Return type:

ValidationResult

class dal.validation.Template(**kwargs)

Bases: object

Loads a config file from json based on a given schema

Example

protocol_config = {

“name”: str, “parameters”: dict,

}

callback_config = {

“name”: str, “libs”: dict, “file”: str

}

port_config = {

“name”: str, “direction”: str, “protocol”: protocol_config, “callback”: callback_config

}

node_config = {

“logfile”: str, “name”: str, “parameters”: dict, “ports”: [port_config]

}

c = Template.load(“node.json”, node_config, “./tests/configs”)

static load(uri: str, config: dict)

Loads a configuration file, validate against config schema returns a Template object

static load_dict(values: dict, config: dict)

Creates a template from a dictionary