Open jtimpe opened 1 month ago
In order to appropriately format all the error messages regardless of how they're used (cat2 or cat3), i'm going to implement different options for the format_error_context
function, i.e.
def format_error_context(row_schema, friendly_name, item_num, format='prefix'):
"""Format the error message for consistency across cat2 validators."""
match format:
case 'inline':
return f'Item {item_num} ({friendly_name})'
case 'prefix' | _:
return f'{row_schema.record_type} Item {item_num} ({friendly_name}):'
this will require a lot of changes (the context needs to be passed along to all of the validators and used in the format_error_context
call) but should allow us to continue to use the same validator functions, and make all of the cat2 validator functions available to the cat3 if_then_validator
.
getting the field
information from the row schema within if_then_validator
turned out to be simple:
field = row_schema.get_field_by_name(condition_field_name)
which allows the field.friendly_name
and field.item
to be passed to the cat2 validator functions (along with the new 'inline'
option)
validator1_result = condition_function(value1, row_schema, condition_field.friendly_name, condition_field.item, 'inline')
Together, these changes should set up #2792 to be completed relatively easily. So far I have both implemented, but have roughly 2 points remaining to finish out the tests.
3 points remaining.
2 points remaining, PR coming soon.
Pending 1 more Raft review.
Description:
2963 makes updates to cat2 validators to include information about the record/field (schema, item number, and friendly name) within the error message. This has a little side effect when the same cat2 validator functions are used within cat3 if/then validators - the item numbers are wrong and the error message contains the extra information for each field and becomes overwhelming/hard to read
if family affiliation :1 validator1 passed then social security number T2 Item -1 (social security number): 000000000 is in ['000000000', '111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'].
Investigate cleaning up the cat3 error messages. Some possible approaches:
Support References
2792
Open Questions: Please include any questions, possible solutions or decisions that should be explored during work
Deliverable(s): Create a list of recommendations or proofs of concept to be achieved to complete this issue