angelos.lib.validation

Validation framework.

This is a framework for validating objects according to policies. The policies are organized in layers of rings and ring sections, each policy has a serial number and a description of its purpose. When an object is validated, a report is generated containing all validated policys and the result of failed policys.

# Layers:

The layers of policys is divided into 7 rings where 1 is the innermost layer. Each layer can be divided into sections. Each individual policy has a totally unique serial number that is chronological from when the policys where organized, and a description.

Example: 1A-0001; Policy purpose and description.

  • 1: Fields * A: … * B: …

  • 2: Documents * C: … * D: … * E: …

  • 3: Portfolios * F: … * G: … * H: … * J: …

  • 4: Facade * K: … * L: … * M: … * N: …

  • 5: Nodes * P: … * Q: … * R: … * S: …

  • 6: Domain * T: … * U: … * V: … * X: …

  • 7: Network * Y: … * Z: …

class angelos.lib.validation.BaseValidatable

Bases: abc.ABC

Object that can be validated according to specific policies and return a report.

abstract apply_rules(report: Optional[angelos.lib.validation.Rep] = None, identity: uuid.UUID = UUID('00000000-0000-0000-0000-000000000000')) → bool

Apply all the rules defined within.

Example

rules = [

(self._check_something, b’I’, 345)

] return self._checker(rules, report, identity)

Parameters
  • identity (uuid.UUID) – Identity to use if this class is a sub validatable.

  • report (Report) – The journal of the validation result.

Returns (bool):

Result of the rules, True if all passed or False.

class angelos.lib.validation.BaseValidator

Bases: abc.ABC

Validators are classes that is used to validate according to specific policies and stems from this class.

validate()angelos.lib.validation.Rep

Validate its own classes that are validatables.

Returns (Report):

Report with applied and failed policies.

class angelos.lib.validation.Rep(validator: BaseValidator)

Bases: object

Validation report that keeps a record of applied policies and failures.

NULL_IDENTITY = UUID('00000000-0000-0000-0000-000000000000')
NULL_POLICY = (b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 73, 0)
POLICY = {b'A': '1A', b'B': '1B', b'C': '2C', b'D': '2D', b'E': '2E', b'F': '3F', b'G': '3G', b'H': '3H', b'J': '3J', b'K': '4K', b'L': '4L', b'M': '4M', b'N': '4N', b'P': '5P', b'Q': '5Q', b'R': '5R', b'S': '5S', b'T': '6T', b'U': '6U', b'V': '6V', b'X': '6X', b'Y': '7Y', b'Z': '7Z'}
property applied

All applied policies.

property failed

All failed policies.

record(identity: uuid.UUID, section: bytes, sn: int, failed: bool = False)

Add a policy record.

Parameters
  • identity (uuid.UUID) – The identity of the object having policies checked.

  • section (bytes) – Policy section from which layer is calculated.

  • sn (int) – Policy chronological serial number.

  • failed (bool) – True or False whether the check failed.