Available rules for the OSI validation

class osivalidator.osi_rules_checker.OSIRulesChecker(ovr, logger, id_manager, ignore_lanes)[source]

This class contains all the available rules to write OSI requirements and the necessary methods to check their compliance.

The rule methods are marked with Rule.

check_message(inherit, rules, id_manager=None)[source]

Method to check the rules for a complex message It is also the input method

Parameters:
  • inherit – a list representing the inheritance of the processed message in tuples
  • rules – the dictionary for the rules rooted at the type of the processed message

Note

inherit parameter must have this structure: [(None, Root message), (Field descriptor, Child message), ...]

The last tuple represents the processed message.

first_element(**kwargs)[source]

Rule

Check rule for first message of a repeated field.

Parameters:params – dictionary of rules to be checked for the first message
in_range(**kwargs)[source]

Rule

Check if a number is in a range.

Parameters:params

must be a table. The first element is the minimum, the second element is the maximum. The first element, if present, is a parameter string:

  • if it contains ‘lo’, the interval is left-open
  • if it contains ‘ro’, the interval is right-open

The interval can be ‘loro’, that is left and right-open.

is_global_unique(**kwargs)[source]

Rule

Register an ID in the OSI ID manager to later perform a ID consistency validation.

Must be set to an Identifier.

is_iso_country_code(**kwargs)[source]

Rule

Check if a string is a ISO country code.

is_maximum(**kwargs)[source]

Rule

Check if a number is under a maximum.

Parameters:params – the maximum
is_minimum(**kwargs)[source]

Rule

Check if a number is over a minimum.

is_set(**kwargs)[source]

Rule

Check if a field is set. The Python function is actually a wrapper of is_valid. The setting of the field is checked during the exploration of the fields.

is_set_if(**kwargs)[source]

Rule

A wrapper to the function is_set. The condition should be contained in params as a string but is checked during the exploration of the message.

Parameters:params – The assertion in Python-style pseudo-code as a string.
is_valid(**kwargs)[source]

Rule

Check if a field message is valid, that is all the inner rules of the message in the field are complying.

last_element(**kwargs)[source]

Rule

Check rule for last message of a repeated field.

Parameters:params – dictionary of rules to be checked for the last message
refers(**kwargs)[source]

Rule

Add a reference to another message by ID.

TODO: the conditional reference. Still no case of use in OSI let this pending.

Parameters:params – id of the refered object
set_timestamp(timestamp)[source]

Set the timestamp for the analysis