Skip to content

Commit

Permalink
Merge pull request #1015 from VisLab/test_branch
Browse files Browse the repository at this point in the history
Updated validation of value tests to better handle value classes based on regex
  • Loading branch information
VisLab authored Sep 22, 2024
2 parents 56415cb + 5f05c97 commit d777427
Show file tree
Hide file tree
Showing 17 changed files with 23,698 additions and 2,075 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,5 @@ Desktop.ini
schema_cache_test/
hed_cache/
spec_tests/hed-specification/tests
spec_tests/hed-examples
spec_tests/*.json
16 changes: 14 additions & 2 deletions hed/errors/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def val_error_element_deprecatedr(tag):
def val_error_invalid_tag_character(tag, problem_tag):
return f"Invalid character '{problem_tag}' in tag '{tag}'"

@hed_tag_error(ValidationErrors.INVALID_VALUE_CLASS_CHARACTER, has_sub_tag=True,
actual_code=ValidationErrors.CHARACTER_INVALID)
def val_error_INVALID_VALUE_CLASS_CHARACTER(tag, problem_tag, value_class):
return f"Invalid character '{problem_tag}' in tag '{tag}' for value class '{value_class}'"

@hed_tag_error(ValidationErrors.INVALID_VALUE_CLASS_VALUE, has_sub_tag=True,
actual_code=ValidationErrors.VALUE_INVALID)
def val_error_INVALID_VALUE_CLASS_VALUE(tag, problem_tag, value_class):
return f"'{tag}' has an invalid value portion for value class '{value_class}'"

@hed_error(ValidationErrors.TILDES_UNSUPPORTED)
def val_error_tildes_not_supported(source_string, char_index):
Expand Down Expand Up @@ -124,8 +133,11 @@ def val_error_no_valid_tag(tag, problem_tag):


@hed_tag_error(ValidationErrors.VALUE_INVALID)
def val_error_no_value(tag):
return f"'{tag}' has an invalid value portion."
def val_error_no_value(tag, value_class=''):
if value_class:
return f"'{tag}' has an invalid value portion because it is not a valid '{value_class}' value."
else:
return f"'{tag}' has an invalid value portion."


@hed_error(ValidationErrors.HED_MISSING_REQUIRED_COLUMN, default_severity=ErrorSeverity.WARNING)
Expand Down
3 changes: 2 additions & 1 deletion hed/errors/error_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class ValidationErrors:
DUPLICATE_COLUMN_BETWEEN_SOURCES = "DUPLICATE_COLUMN_BETWEEN_SOURCES"
HED_BLANK_COLUMN = "HED_BLANK_COLUMN"


INVALID_VALUE_CLASS_CHARACTER = 'INVALID_VALUE_CLASS_CHARACTER'
INVALID_VALUE_CLASS_VALUE = 'INVALID_VALUE_CLASS_VALUE'
INVALID_TAG_CHARACTER = 'invalidTagCharacter'

CURLY_BRACE_UNSUPPORTED_HERE = "CURLY_BRACE_UNSUPPORTED_HERE"
Expand Down
Loading

0 comments on commit d777427

Please sign in to comment.