Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated validation of value tests to better handle value classes based on regex #1015

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading