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:
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:
objectLoads 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:
objectValidator 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:
objectConfirm 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:
ProtocolProtocol 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:
objectValidator 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.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:
- class dal.validation.Template(**kwargs)
Bases:
objectLoads 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