CharValidator¶
- class CharValidator(modern_allowed_char_rules=False)[source]
Class responsible for basic character level validation of a string or tag.
Methods
|
Does basic character validation for HED strings/tags |
Report invalid characters in extension/value. |
|
Report invalid characters. |
|
Report invalid characters in the given tag. |
Attributes
- CharValidator.__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.
- CharValidator.check_for_invalid_extension_chars(original_tag, validate_text, error_code=None, index_offset=0)[source]¶
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
- CharValidator.check_invalid_character_issues(hed_string, allow_placeholders)[source]¶
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
- CharValidator.check_tag_invalid_chars(original_tag, allow_placeholders)[source]¶
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
- CharValidator.DEFAULT_ALLOWED_PLACEHOLDER_CHARS = '.+-^ _#'¶
- CharValidator.INVALID_STRING_CHARS = '[]{}~'¶
- CharValidator.INVALID_STRING_CHARS_PLACEHOLDERS = '[]~'¶
- CharValidator.TAG_ALLOWED_CHARS = '-_/'¶