HedValidator

class HedValidator(hed_schema, def_dicts=None, definitions_allowed=False)[source]

Top level validation of HED strings.

Methods

HedValidator.__init__(hed_schema[, ...])

Constructor for the HedValidator class.

HedValidator.check_tag_formatting(original_tag)

Report repeated or erroneous slashes.

HedValidator.run_basic_checks(hed_string, ...)

HedValidator.run_full_string_checks(hed_string)

HedValidator.validate(hed_string, ...[, ...])

Validate the string using the schema

HedValidator.validate_units(original_tag[, ...])

Validate units and value classes

Attributes

HedValidator.pattern_doubleslash

HedValidator.__init__(hed_schema, def_dicts=None, definitions_allowed=False)[source]

Constructor for the HedValidator class.

Parameters:
  • hed_schema (HedSchema or HedSchemaGroup) – HedSchema object to use for validation.

  • def_dicts (DefinitionDict or list or dict) – the def dicts to use for validation

  • definitions_allowed (bool) – If False, flag definitions found as errors

HedValidator.check_tag_formatting(original_tag)[source]

Report repeated or erroneous slashes.

Parameters:

original_tag (HedTag) – The original tag that is used to report the error.

Returns:

Validation issues. Each issue is a dictionary.

Return type:

list

HedValidator.run_basic_checks(hed_string, allow_placeholders)[source]
HedValidator.run_full_string_checks(hed_string)[source]
HedValidator.validate(hed_string, allow_placeholders, error_handler=None)[source]

Validate the string using the schema

Parameters:
  • hed_string (HedString) – the string to validate

  • allow_placeholders (bool) – allow placeholders in the string

  • error_handler (ErrorHandler or None) – the error handler to use, creates a default one if none passed

Returns:

A list of issues for hed string

Return type:

issues (list of dict)

HedValidator.validate_units(original_tag, validate_text=None, report_as=None, error_code=None, index_offset=0)[source]

Validate units and value classes

Parameters:
  • original_tag (HedTag) – The source tag

  • validate_text (str) – the text we want to validate, if not the full extension.

  • report_as (HedTag) – Report the error tag as coming from a different one. Mostly for definitions that expand.

  • error_code (str) – The code to override the error as. Again mostly for def/def-expand tags.

  • index_offset (int) – Offset into the extension validate_text starts at

Returns:

Issues found from units

Return type:

issues(list)

HedValidator.pattern_doubleslash = re.compile('([ \\t/]{2,}|^/|/$)')