CharRexValidator

class CharRexValidator(modern_allowed_char_rules=False)[source]

Class responsible for basic character level validation of a string or tag.

Methods

CharRexValidator.__init__([...])

Does basic character validation for HED strings/tags

CharRexValidator.check_for_invalid_extension_chars(...)

Report invalid characters in extension/value.

CharRexValidator.check_invalid_character_issues(...)

Report invalid characters.

CharRexValidator.check_tag_invalid_chars(...)

Report invalid characters in the given tag.

CharRexValidator.get_problem_chars(...)

CharRexValidator.is_valid_value(...)

Attributes

CharRexValidator.DEFAULT_ALLOWED_PLACEHOLDER_CHARS

CharRexValidator.INVALID_STRING_CHARS

CharRexValidator.INVALID_STRING_CHARS_PLACEHOLDERS

CharRexValidator.TAG_ALLOWED_CHARS

CharRexValidator.__init__(modern_allowed_char_rules=False)[source]

Does basic character validation for HED strings/tags

Parameters:

modern_allowed_char_rules (bool) – If True, use 8.3 style rules for unicode characters.

CharRexValidator.check_for_invalid_extension_chars(original_tag, validate_text, error_code=None, index_offset=0)

Report invalid characters in extension/value.

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

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

  • 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:

Validation issues. Each issue is a dictionary.

Return type:

list

CharRexValidator.check_invalid_character_issues(hed_string, allow_placeholders)

Report invalid characters.

Parameters:
  • hed_string (str) – A HED string.

  • allow_placeholders (bool) – Allow placeholder and curly brace characters.

Returns:

Validation issues. Each issue is a dictionary.

Return type:

list

Notes

  • Invalid tag characters are defined by self.INVALID_STRING_CHARS or

    self.INVALID_STRING_CHARS_PLACEHOLDERS

CharRexValidator.check_tag_invalid_chars(original_tag, allow_placeholders)

Report invalid characters in the given tag.

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

  • allow_placeholders (bool) – Allow placeholder characters(#) if True.

Returns:

Validation issues. Each issue is a dictionary.

Return type:

list

CharRexValidator.get_problem_chars(input_string, class_name)[source]
CharRexValidator.is_valid_value(input_string, class_name)[source]
CharRexValidator.DEFAULT_ALLOWED_PLACEHOLDER_CHARS = '.+-^ _#'
CharRexValidator.INVALID_STRING_CHARS = '[]{}~'
CharRexValidator.INVALID_STRING_CHARS_PLACEHOLDERS = '[]~'
CharRexValidator.TAG_ALLOWED_CHARS = '-_/'