From 1d729d8a17a7ac49dd1cc4805ec22526f27385c6 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 04:29:27 -0400 Subject: [PATCH 01/11] Task 33, adding validatio id --- src/validator/checks.py | 26 ++-- src/validator/create_schemas.py | 5 +- src/validator/phase_validations.py | 221 +++++++++++++++++++++++++---- 3 files changed, 212 insertions(+), 40 deletions(-) diff --git a/src/validator/checks.py b/src/validator/checks.py index d8a6ca17..0744f629 100644 --- a/src/validator/checks.py +++ b/src/validator/checks.py @@ -14,7 +14,7 @@ name="Just a Warning" ) - error_check_implied = SBLCheck(lambda: Truename="Error Check") + error_check_implied = SBLCheck(lambda: True name="Error Check") error_check_explicit = SBLCheck( lambda: True, @@ -32,7 +32,7 @@ class SBLCheck(Check): - """A custom Pandera.Check subclasss that requires a `name` be + """A custom Pandera.Check subclasss that requires a `name` and an `id` be specified. Additionally, an attribute named `warning` is added to the class to enable distinction between warnings and errors. The default value of warning is `False` which corresponds to an error. @@ -40,23 +40,29 @@ class SBLCheck(Check): Don't use this class directly. Make use of the SBLErrorCheck and SBLWarningCheck subclasses below.""" - def __init__(self, check_fn: Callable, warning=False, *args, **kwargs): - """Custom init method that verifies the presence of `name` in + def __init__( + self, check_fn: Callable, id: str = None, warning=False, *args, **kwargs + ): + """Custom init method that verifies the presence of `name` and `id` in kwargs creates a custom class attribute called `warning`. All other initializaiton is handled by the parent Check class. Args: check_fn (Callable): A function which evaluates the validity of the column(s) being tested. + id (str, required): Each check mut have an id. warning (bool, optional): Boolean specifying whether to treat the check as a warning rather than an error. Raises: - ValueError: Raised if `name` not supplied in kwargs. + ValueError: Raised if `name` not supplied in kwargs and if id is not + supplied or None. """ - if "name" not in kwargs: - raise ValueError("Each check must be assigned a `name`.") + self.id = id + + if "name" not in kwargs or id is None: + raise ValueError("Each check must be assigned a `name` and an `id`.") # if warning==False treat check as an error check self.warning = warning @@ -68,9 +74,3 @@ def get_backend(cls, check_obj: Any) -> Type[BaseCheckBackend]: """Assume Pandas DataFrame and return PandasCheckBackend""" return PandasCheckBackend - -if __name__ == "__main__": - warning_check = SBLCheck(lambda: True, warning=True, name="Just a Warning") - - error_check_implied = SBLCheck(lambda: True, name="Error Check") - error_check_explicit = SBLCheck(lambda: True, warning=False, name="Also an Error") diff --git a/src/validator/create_schemas.py b/src/validator/create_schemas.py index d5c47456..e75123fe 100644 --- a/src/validator/create_schemas.py +++ b/src/validator/create_schemas.py @@ -25,11 +25,13 @@ def print_schema_errors(errors: SchemaErrors, phase: str): # Name of the column in the dataframe being checked schema_error = error["error"] column_name = schema_error.schema.name + check_id = "n/a" # built in checks such as unique=True are different than custom # checks unfortunately so the name needs to be accessed differently try: check_name = schema_error.check.name + check_id = schema_error.check.id # This will either be a boolean series or a single bool check_output = schema_error.check_output except AttributeError: @@ -37,7 +39,8 @@ def print_schema_errors(errors: SchemaErrors, phase: str): # this is just a string that we'd need to parse manually check_output = schema_error.args[0] - print(f"{phase} Validation `{check_name}` failed for column `{column_name}`") + f"{phase} Validation `{check_name}` with id: `{check_id}` \ + failed for column `{column_name}`" print(check_output) print("") diff --git a/src/validator/phase_validations.py b/src/validator/phase_validations.py index d5123ded..c40cf2d5 100644 --- a/src/validator/phase_validations.py +++ b/src/validator/phase_validations.py @@ -5,41 +5,30 @@ import global_data -from check_functions import ( - has_correct_length, - has_no_conditional_field_conflict, - has_valid_enum_pair, - has_valid_fieldset_pair, - has_valid_format, - has_valid_multi_field_value_count, - has_valid_value_count, - is_date, - is_date_after, - is_date_before_in_days, - is_date_in_range, - is_greater_than, - is_greater_than_or_equal_to, - is_less_than, - is_number, - is_unique_column, - is_unique_in_field, - is_valid_code, - is_valid_enum, - meets_multi_value_field_restriction, - string_contains, -) +from check_functions import (has_correct_length, + has_no_conditional_field_conflict, + has_valid_enum_pair, has_valid_fieldset_pair, + has_valid_format, + has_valid_multi_field_value_count, + has_valid_value_count, is_date, is_date_after, + is_date_before_in_days, is_date_in_range, + is_greater_than, is_greater_than_or_equal_to, + is_less_than, is_number, is_unique_column, + is_unique_in_field, is_valid_code, is_valid_enum, + meets_multi_value_field_restriction, + string_contains) from checks import SBLCheck # read and populate global naics code (this should be called only once) global_data.read_naics_codes() - def get_phase_1_and_2_validations_for_lei(lei: str = None): return { "uid": { "phase_1": [ SBLCheck( is_unique_column, + id="E3000", name="uid.duplicates_in_dataset", description=( "Any 'unique identifier' may not be used in more than one " @@ -50,6 +39,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 21, 45, + id="E0001", name="uid.invalid_text_length", description=( "'Unique identifier' must be at least 21 characters " @@ -58,6 +48,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_format, + id="E0002", name="uid.invalid_text_pattern", description=( "'Unique identifier' may contain any combination of " @@ -69,6 +60,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( string_contains, + id="W0003", name="uid.invalid_uid_lei", description=( "The first 20 characters of the 'unique identifier' should" @@ -86,6 +78,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_date, + id="E0020", name="app_date.invalid_date_format", description=( "'Application date' must be a real calendar " @@ -100,6 +93,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0040", name="app_method.invalid_enum_value", description="'Application method' must equal 1, 2, 3, or 4.", element_wise=True, @@ -117,6 +111,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0060", name="app_recipient.invalid_enum_value", description="'Application recipient' must equal 1 or 2", element_wise=True, @@ -132,10 +127,11 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0080", name="ct_credit_product.invalid_enum_value", description=( - "'Credit product' must equal 1, 2, 3, 4, 5, 6, " - "7, 8, 977, or 988." + "'Credit product' must equal 1, 2, 3, 4, 5, 6, 7, 8, " + "977, or 988." ), element_wise=True, accepted_values=[ @@ -159,6 +155,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0100", name="ct_credit_product_ff.invalid_text_length", description=( "'Free-form text field for other credit products' " @@ -169,6 +166,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2000", name="ct_credit_product_ff.conditional_field_conflict", description=( "When 'credit product' does not equal 977 (other), 'free-form" @@ -185,6 +183,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0120", name="ct_guarantee.invalid_enum_value", description=( "Each value in 'type of guarantee' (separated by " @@ -212,6 +211,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_value_count, + id="E0121", name="ct_guarantee.invalid_number_of_values", description=( "'Type of guarantee' must contain at least one and at" @@ -223,6 +223,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_unique_in_field, + id="W0123", warning=True, name="ct_guarantee.duplicates_in_field", description=( @@ -232,6 +233,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0122", warning=True, name="ct_guarantee.multi_value_field_restriction", description=( @@ -249,6 +251,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0140", name="ct_guarantee_ff.invalid_text_length", description=( "'Free-form text field for other guarantee' must not " @@ -259,6 +262,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2001", name="ct_guarantee_ff.conditional_field_conflict", description=( "When 'type of guarantee' does not contain 977 (other), " @@ -271,6 +275,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_multi_field_value_count, + id="W2006", warning=True, name="ct_guarantee_ff.multi_invalid_number_of_values", description=( @@ -290,6 +295,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0160", name="ct_loan_term_flag.invalid_enum_value", description=( "Each value in 'Loan term: NA/NP flag' (separated by " @@ -306,6 +312,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_enum_pair, + id="E2003", name="ct_loan_term_flag.enum_value_conflict", description=( "When 'credit product' equals 1 (term loan - unsecured) or 2" @@ -337,6 +344,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0180", name="ct_loan_term.invalid_numeric_format", description="When present, 'loan term' must be a whole number.", element_wise=True, @@ -346,6 +354,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2004", name="ct_loan_term.conditional_field_conflict", description=( "When 'loan term: NA/NP flag' does not equal 900 (applicable " @@ -357,6 +366,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_greater_than_or_equal_to, + id="E0181", name="ct_loan_term.invalid_numeric_value", description=( "When present, 'loan term' must be greater than or equal" @@ -368,6 +378,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_less_than, + id="W0182", name="ct_loan_term.unreasonable_numeric_value", description=( "When present, 'loan term' should be less than 1200" @@ -383,6 +394,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0200", name="credit_purpose.invalid_enum_value", description=( "Each value in 'credit purpose' (separated by " @@ -411,6 +423,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_value_count, + id="E0201", name="credit_purpose.invalid_number_of_values", description=( "'Credit purpose' must contain at least one and at" @@ -422,6 +435,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0202", warning=True, name="credit_purpose.multi_value_field_restriction", description=( @@ -437,6 +451,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_unique_in_field, + id="W0203", warning=True, name="credit_purpose.duplicates_in_field", description=( @@ -451,6 +466,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0220", name="credit_purpose_ff.invalid_text_length", description=( "'Free-form text field for other credit purpose' " @@ -461,6 +477,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2005", name="credit_purpose_ff.conditional_field_conflict", description=( "When 'credit purpose' does not contain 977 (other)," @@ -473,6 +490,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_value_count, + id="W2006", name="credit_purpose_ff.invalid_number_of_values", description=( "'Other Credit purpose' must not contain more " @@ -488,6 +506,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0240", name="amount_applied_for_flag.invalid_enum_value", description=( "'Amount applied For: NA/NP flag' must equal 900, 988, or 999." @@ -506,6 +525,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0260", name="amount_applied_for.invalid_numeric_format", description=( "When present, 'amount applied for' must be a numeric" "value." @@ -517,6 +537,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2007", name="amount_applied_for.conditional_field_conflict", description=( "When 'amount applied for: NA/NP flag' does not equal 900 " @@ -529,6 +550,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_greater_than, + id="E0261", name="amount_applied_for.invalid_numeric_value", description=( "When present, 'amount applied for' must be greater than 0." @@ -543,6 +565,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0280", name="amount_approved.invalid_numeric_format", description=( "When present, 'amount approved or originated' " @@ -555,6 +578,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_greater_than, + id="E0281", name="amount_approved.invalid_numeric_value", description=( "When present, 'amount approved or originated' " @@ -566,6 +590,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_no_conditional_field_conflict, + id="E2008", name="amount_approved.conditional_field_conflict", description=( "When 'action taken' does not equal 1 (originated) " @@ -583,6 +608,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0300", name="action_taken.invalid_enum_value", description="'Action taken' must equal 1, 2, 3, 4, or 5.", element_wise=True, @@ -598,6 +624,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_fieldset_pair, + id="E2014", name="pricing_all.conditional_fieldset_conflict", description=( "When 'action taken' equals 3 (denied), " @@ -635,6 +662,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_fieldset_pair, + id="E2015", name="pricing_charges.conditional_fieldset_conflict", description=( "When 'action taken' equals 1 (originated)" @@ -669,6 +697,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_date, + id="E0320", name="action_taken_date.invalid_date_format", description=( "'Action taken date' must be a real calendar" @@ -680,6 +709,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_date_in_range, + id="E0321", name="action_taken_date.invalid_date_value", description=( "The date indicated by 'action taken date' must occur" @@ -692,6 +722,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_date_after, + id="E2009", name="action_taken_date.date_value_conflict", description=( "The date indicated by 'action taken date'" @@ -701,6 +732,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_date_before_in_days, + id="W2010", name="action_taken_date.unreasonable_date_value", description=( "The date indicated by 'application date' should" @@ -716,6 +748,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0001", name="denial_reasons.invalid_enum_value", description=( "Each value in 'denial reason(s)' (separated by semicolons)" @@ -740,6 +773,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_value_count, + id="E0341", name="denial_reasons.invalid_number_of_values", description=( "'Denial reason(s)' must contain at least one and at most four" @@ -751,6 +785,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_enum_pair, + id="E2011", name="denial_reasons.enum_value_conflict", description=( "When 'action taken' equals 3, 'denial reason(s)' must not" @@ -775,6 +810,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0340", warning=True, name="denial_reasons.multi_value_field_restriction", description=( @@ -786,6 +822,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_unique_in_field, + id="W0341", warning=True, name="denial_reasons.duplicates_in_field", description=( @@ -800,6 +837,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( min_value=0, max_value=300, + id="E0360", name="denial_reasons_ff.invalid_text_length", description=( "'Free-form text field for other denial reason(s)'" @@ -810,6 +848,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2012", name="denial_reasons_ff.conditional_field_conflict", description=( "When 'denial reason(s)' does not contain 977 (other), field" @@ -826,6 +865,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0380", name="pricing_interest_rate_type.invalid_enum_value", description=( "Each value in 'Interest rate type' (separated by " @@ -849,6 +889,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0400", name="pricing_init_rate_period.invalid_numeric_format", description=( "When present, 'initial rate period' must be a whole number.", @@ -860,6 +901,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2016", name="pricing_init_rate_period.conditional_field_conflict", description=( "When 'interest rate type' does not equal 3 (initial rate " @@ -875,6 +917,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_greater_than, + id="E0401", name="pricing_init_rate_period.invalid_numeric_value", description=( "When present, 'initial rate period' must be greater than 0", @@ -889,6 +932,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0420", name="pricing_fixed_rate.invalid_numeric_format", description=( "When present, 'fixed rate: interest rate'" @@ -901,6 +945,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2017", name="pricing_fixed_rate.conditional_field_conflict", description=( "When 'interest rate type' does not equal 2" @@ -916,6 +961,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_greater_than, + id="W0420", name="pricing_fixed_rate.unreasonable_numeric_value", description=( "When present, 'fixed rate: interest rate'" @@ -931,6 +977,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0440", name="pricing_adj_margin.invalid_numeric_format", description=( "When present, 'adjustable rate transaction:" @@ -943,6 +990,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2018", name="pricing_adj_margin.conditional_field_conflict", description=( "When 'interest rate type' does not equal 1" @@ -958,6 +1006,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_greater_than, + id="E0001", name="pricing_adj_margin.unreasonable_numeric_value", description=( "When present, 'adjustable rate transaction:" @@ -973,6 +1022,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0460", name="pricing_adj_index_name.invalid_enum_value", description=( "'Adjustable rate transaction: index name' must equal " @@ -998,6 +1048,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_enum_pair, + id="E2019", name="pricing_adj_index_name.enum_value_conflict", description=( "When 'interest rate type' does not equal 1 (variable interest" @@ -1031,6 +1082,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( min_value=0, max_value=300, + id="E0480", name="pricing_adj_index_name_ff.invalid_text_length", description=( "'Adjustable rate transaction: index name: other' must not" @@ -1041,6 +1093,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2020", name="pricing_adj_index_name_ff.conditional_field_conflict", description=( "When 'adjustable rate transaction: index name' does not equal" @@ -1059,6 +1112,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0500", name="pricing_adj_index_value.invalid_numeric_format", description="When present, 'adjustable rate transaction:" " index value' must be a numeric value.", @@ -1069,6 +1123,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2021", name="pricing_adj_index_value.conditional_field_conflict", description=( "When 'interest rate type' does not equal 1 (variable" @@ -1087,6 +1142,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0520", name="pricing_origination_charges.invalid_numeric_format", description=( "When present, 'total origination charges' must be a numeric", @@ -1102,6 +1158,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0540", name="pricing_broker_fees.invalid_numeric_format", description=( "When present, 'amount of total broker fees' must be a", @@ -1117,6 +1174,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0560", name="pricing_initial_charges.invalid_numeric_format", description=( "When present, 'initial annual charges' must be a" @@ -1132,6 +1190,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0580", name="pricing_mca_addcost_flag.invalid_enum_value", description=( "'MCA/sales-based: additional cost for merchant cash " @@ -1148,6 +1207,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_enum_pair, + id="E2022", name="pricing_mca_addcost_flag.enum_value_conflict", description=( "When 'credit product' does not equal 7 (merchant cash " @@ -1172,6 +1232,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0600", name="pricing_mca_addcost.invalid_numeric_format", description=( "When present, 'MCA/sales-based: additional cost for " @@ -1185,6 +1246,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2023", name="pricing_mca_addcost.conditional_field_conflict", description=( "When 'MCA/sales-based: additional cost for merchant " @@ -1206,6 +1268,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0620", name="pricing_prepenalty_allowed.invalid_enum_value", description=( "'Prepayment penalty could be imposed' must equal 1, 2, or 999." @@ -1224,6 +1287,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0640", name="pricing_prepenalty_exists.invalid_enum_value", description="'Prepayment penalty exists' must equal 1, 2, or 999.", element_wise=True, @@ -1240,6 +1304,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0640", name="census_tract_adr_type.invalid_enum_value", description=( "'Census tract: type of address' must equal 1, 2, 3, or 988." @@ -1259,6 +1324,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( has_correct_length, + id="E0680", name="census_tract_number.invalid_text_length", description=( "When present, 'census tract: tract number' must " @@ -1272,6 +1338,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_enum_pair, + id="E2024", name="census_tract_number.conditional_field_conflict", description=( "When 'census tract: type of address' equals 988 (not " @@ -1306,6 +1373,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0700", name="gross_annual_revenue_flag.invalid_enum_value", description=( "'Gross annual revenue: NP flag' must equal 900 or 988." @@ -1323,6 +1391,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0720", name="gross_annual_revenue.invalid_numeric_format", description=( "When present, 'gross annual revenue' must be a numeric value." @@ -1334,6 +1403,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2025", name="gross_annual_revenue.conditional_field_conflict", description=( "When 'gross annual revenue: NP flag' does not equal 900 " @@ -1350,6 +1420,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0720", name="naics_code_flag.invalid_enum_value", description=( "'North American Industry Classification System (NAICS) " @@ -1368,6 +1439,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0761", name="naics_code.invalid_naics_format", description=( "'North American Industry Classification System " @@ -1380,6 +1452,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_correct_length, + id="E0760", name="naics_code.invalid_text_length", description=( "When present, 'North American Industry Classification System " @@ -1391,6 +1464,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_valid_code, + id="W0762", name="naics_code.invalid_naics_value", description=( "When present, 'North American Industry Classification System " @@ -1402,6 +1476,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_no_conditional_field_conflict, + id="E2026", name="naics_code.conditional_field_conflict", description=( "When 'type of guarantee' does not contain 977 (other), " @@ -1418,6 +1493,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0780", name="number_of_workers.invalid_enum_value", description=( "'Number of workers' must equal 1, 2, 3, 4, 5, 6, 7, 8, 9," @@ -1444,6 +1520,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0800", name="time_in_business_type.invalid_enum_value", description=( "'Time in business: type of response'" @@ -1464,6 +1541,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_number, + id="E0820", name="time_in_business.invalid_numeric_format", description=( "When present, 'time in business' must be a whole number." @@ -1475,6 +1553,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_greater_than_or_equal_to, + id="E0821", name="time_in_business.invalid_numeric_value", description=( "When present, 'time in business'" @@ -1486,6 +1565,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_no_conditional_field_conflict, + id="E2027", name="time_in_business.conditional_field_conflict", description=( "When 'time in business: type of response' does not" @@ -1504,6 +1584,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0840", name="business_ownership_status.invalid_enum_value", description=( "Each value in 'business ownership status'" @@ -1524,6 +1605,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_value_count, + id="E0841", name="business_ownership_status.invalid_number_of_values", description=( "'Business ownership status' must" @@ -1534,6 +1616,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( is_unique_in_field, + id="W0842", warning=True, name="business_ownership_status.duplicates_in_field", description=( @@ -1544,6 +1627,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0843", warning=True, name="business_ownership_status.multi_value_field_restriction", description=( @@ -1562,6 +1646,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0860", name="num_principal_owners_flag.invalid_enum_value", description=( "'Number of principal owners: NP flag' must equal 900 or 988." @@ -1576,6 +1661,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_valid_fieldset_pair, + id="W2035", name="po_demographics_0.conditional_fieldset_conflict", description=( "When 'number of principal owners' equals 0 or is blank, " @@ -1614,6 +1700,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_fieldset_pair, + id="W2036", name="po_demographics_1.conditional_fieldset_conflict", description=( "When 'number of principal owners' equals 1, " @@ -1654,6 +1741,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_fieldset_pair, + id="W2037", name="po_demographics_2.conditional_fieldset_conflict", description=( "When 'number of principal owners' equals 2, " @@ -1693,6 +1781,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_fieldset_pair, + id="W2038", name="po_demographics_3.conditional_fieldset_conflict", description=( "When 'number of principal owners' equals 3, " @@ -1733,6 +1822,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( has_valid_fieldset_pair, + id="W2039", name="po_demographics_4.conditional_fieldset_conflict", description=( "When 'number of principal owners' equals 4, " @@ -1777,6 +1867,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0880", name="num_principal_owners.invalid_enum_value", description=( "When present, 'number of principal owners' must equal " @@ -1790,6 +1881,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2028", name="num_principal_owners.conditional_field_conflict", description=( "When 'number of principal owners: NP flag' does not equal 900 " @@ -1806,6 +1898,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0900", name="po_1_ethnicity.invalid_enum_value", description=( "When present, each value in 'ethnicity" @@ -1831,6 +1924,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0901", warning=True, name="po_1_ethnicity.duplicates_in_field", description=( @@ -1841,6 +1935,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0902", warning=True, name="po_1_ethnicity.multi_value_field_restriction", description=( @@ -1860,6 +1955,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0920", name="po_1_ethnicity_ff.invalid_text_length", description=( "'Ethnicity of principal owner 1: free-form" @@ -1871,6 +1967,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2029", name="po_1_ethnicity_ff.conditional_field_conflict", description=( "When 'ethnicity of principal owner 1' does not" @@ -1891,6 +1988,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0940", name="po_1_race.invalid_enum_value", description=( "When present, each value in 'race" @@ -1938,6 +2036,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0941", warning=True, name="po_1_race.duplicates_in_field", description=( @@ -1948,6 +2047,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0942", warning=True, name="po_1_race.multi_value_field_restriction", description=( @@ -1968,6 +2068,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0960", name="po_1_race_anai_ff.invalid_text_length", description=( "'Race of principal owner 1: free-form" @@ -1980,6 +2081,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2030", name="po_1_race_anai_ff.conditional_field_conflict", description=( "When 'race of principal owner 1' does not" @@ -2004,6 +2106,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0980", name="po_1_race_asian_ff.invalid_text_length", description=( "'Race of principal owner 1: free-form text" @@ -2015,6 +2118,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2031", name="po_1_race_asian_ff.conditional_field_conflict", description=( "When 'race of principal owner 1' does not contain" @@ -2035,6 +2139,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1000", name="po_1_race_baa_ff.invalid_text_length", description=( "'Race of principal owner 1: free-form text" @@ -2046,6 +2151,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2032", name="po_1_race_baa_ff.conditional_field_conflict", description=( "When 'race of principal owner 1' does not contain 973" @@ -2066,6 +2172,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1020", name="po_1_race_pi_ff.invalid_text_length", description=( "'Race of principal owner 1: free-form text" @@ -2077,6 +2184,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2033", name="po_1_race_pi_ff.conditional_field_conflict", description=( "When 'race of principal owner 1' does not contain 974" @@ -2096,6 +2204,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E1040", name="po_1_gender_flag.invalid_enum_value", description=( "When present, 'sex/gender of principal" @@ -2117,6 +2226,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1060", name="po_1_gender_ff.invalid_text_length", description=( "'Sex/gender of principal owner 1: free-form" @@ -2128,6 +2238,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2034", name="po_1_gender_ff.conditional_field_conflict", description=( "When 'sex/gender of principal owner 1: NP flag'" @@ -2148,6 +2259,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0900", name="po_2_ethnicity.invalid_enum_value", description=( "When present, each value in 'ethnicity" @@ -2173,6 +2285,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0901", warning=True, name="po_2_ethnicity.duplicates_in_field", description=( @@ -2183,6 +2296,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0902", warning=True, name="po_2_ethnicity.multi_value_field_restriction", description=( @@ -2202,6 +2316,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0920", name="po_2_ethnicity_ff.invalid_text_length", description=( "'Ethnicity of principal owner 2: free-form" @@ -2213,6 +2328,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2029", name="po_2_ethnicity_ff.conditional_field_conflict", description=( "When 'ethnicity of principal owner 2' does not" @@ -2233,6 +2349,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0940", name="po_2_race.invalid_enum_value", description=( "When present, each value in 'race" @@ -2280,6 +2397,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0941", warning=True, name="po_2_race.duplicates_in_field", description=( @@ -2290,6 +2408,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0942", warning=True, name="po_2_race.multi_value_field_restriction", description=( @@ -2310,6 +2429,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0960", name="po_2_race_anai_ff.invalid_text_length", description=( "'Race of principal owner 2: free-form" @@ -2322,6 +2442,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2030", name="po_2_race_anai_ff.conditional_field_conflict", description=( "When 'race of principal owner 2' does not" @@ -2346,6 +2467,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0980", name="po_2_race_asian_ff.invalid_text_length", description=( "'Race of principal owner 2: free-form text" @@ -2357,6 +2479,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2031", name="po_2_race_asian_ff.conditional_field_conflict", description=( "When 'race of principal owner 2' does not contain" @@ -2377,6 +2500,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1000", name="po_2_race_baa_ff.invalid_text_length", description=( "'Race of principal owner 2: free-form text" @@ -2388,6 +2512,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2032", name="po_2_race_baa_ff.conditional_field_conflict", description=( "When 'race of principal owner 2' does not contain 973" @@ -2408,6 +2533,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1020", name="po_2_race_pi_ff.invalid_text_length", description=( "'Race of principal owner 2: free-form text" @@ -2419,6 +2545,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2033", name="po_2_race_pi_ff.conditional_field_conflict", description=( "When 'race of principal owner 2' does not contain 974" @@ -2438,6 +2565,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E1040", name="po_2_gender_flag.invalid_enum_value", description=( "When present, 'sex/gender of principal" @@ -2459,6 +2587,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1060", name="po_2_gender_ff.invalid_text_length", description=( "'Sex/gender of principal owner 2: free-form" @@ -2470,6 +2599,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2034", name="po_2_gender_ff.conditional_field_conflict", description=( "When 'sex/gender of principal owner 2: NP flag'" @@ -2490,6 +2620,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0900", name="po_3_ethnicity.invalid_enum_value", description=( "When present, each value in 'ethnicity" @@ -2515,6 +2646,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0901", warning=True, name="po_3_ethnicity.duplicates_in_field", description=( @@ -2525,6 +2657,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0902", warning=True, name="po_3_ethnicity.multi_value_field_restriction", description=( @@ -2544,6 +2677,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0920", name="po_3_ethnicity_ff.invalid_text_length", description=( "'Ethnicity of principal owner 3: free-form" @@ -2555,6 +2689,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2029", name="po_3_ethnicity_ff.conditional_field_conflict", description=( "When 'ethnicity of principal owner 3' does not" @@ -2575,6 +2710,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0940", name="po_3_race.invalid_enum_value", description=( "When present, each value in 'race" @@ -2622,6 +2758,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0941", warning=True, name="po_3_race.duplicates_in_field", description=( @@ -2632,6 +2769,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0942", warning=True, name="po_3_race.multi_value_field_restriction", description=( @@ -2652,6 +2790,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0960", name="po_3_race_anai_ff.invalid_text_length", description=( "'Race of principal owner 3: free-form" @@ -2664,6 +2803,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2030", name="po_3_race_anai_ff.conditional_field_conflict", description=( "When 'race of principal owner 3' does not" @@ -2688,6 +2828,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0980", name="po_3_race_asian_ff.invalid_text_length", description=( "'Race of principal owner 3: free-form text" @@ -2699,6 +2840,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2031", name="po_3_race_asian_ff.conditional_field_conflict", description=( "When 'race of principal owner 3' does not contain" @@ -2719,6 +2861,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1000", name="po_3_race_baa_ff.invalid_text_length", description=( "'Race of principal owner 3: free-form text" @@ -2730,6 +2873,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2032", name="po_3_race_baa_ff.conditional_field_conflict", description=( "When 'race of principal owner 3' does not contain 973" @@ -2750,6 +2894,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1020", name="po_3_race_pi_ff.invalid_text_length", description=( "'Race of principal owner 3: free-form text" @@ -2761,6 +2906,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2033", name="po_3_race_pi_ff.conditional_field_conflict", description=( "When 'race of principal owner 3' does not contain 974" @@ -2780,6 +2926,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E1040", name="po_3_gender_flag.invalid_enum_value", description=( "When present, 'sex/gender of principal" @@ -2801,6 +2948,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1060", name="po_3_gender_ff.invalid_text_length", description=( "'Sex/gender of principal owner 3: free-form" @@ -2812,6 +2960,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2034", name="po_3_gender_ff.conditional_field_conflict", description=( "When 'sex/gender of principal owner 3: NP flag'" @@ -2832,6 +2981,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0900", name="po_4_ethnicity.invalid_enum_value", description=( "When present, each value in 'ethnicity" @@ -2857,6 +3007,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0901", warning=True, name="po_4_ethnicity.duplicates_in_field", description=( @@ -2867,6 +3018,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0902", warning=True, name="po_4_ethnicity.multi_value_field_restriction", description=( @@ -2886,6 +3038,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0920", name="po_4_ethnicity_ff.invalid_text_length", description=( "'Ethnicity of principal owner 4: free-form" @@ -2897,6 +3050,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2029", name="po_4_ethnicity_ff.conditional_field_conflict", description=( "When 'ethnicity of principal owner 4' does not" @@ -2917,6 +3071,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E0940", name="po_4_race.invalid_enum_value", description=( "When present, each value in 'race" @@ -2964,6 +3119,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( is_unique_in_field, + id="W0941", warning=True, name="po_4_race.duplicates_in_field", description=( @@ -2974,6 +3130,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ), SBLCheck( meets_multi_value_field_restriction, + id="W0942", warning=True, name="po_4_race.multi_value_field_restriction", description=( @@ -2994,6 +3151,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0960", name="po_4_race_anai_ff.invalid_text_length", description=( "'Race of principal owner 4: free-form" @@ -3006,6 +3164,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2030", name="po_4_race_anai_ff.conditional_field_conflict", description=( "When 'race of principal owner 4' does not" @@ -3030,6 +3189,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E0980", name="po_4_race_asian_ff.invalid_text_length", description=( "'Race of principal owner 4: free-form text" @@ -3041,6 +3201,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2031", name="po_4_race_asian_ff.conditional_field_conflict", description=( "When 'race of principal owner 4' does not contain" @@ -3061,6 +3222,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1000", name="po_4_race_baa_ff.invalid_text_length", description=( "'Race of principal owner 4: free-form text" @@ -3072,6 +3234,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2032", name="po_4_race_baa_ff.conditional_field_conflict", description=( "When 'race of principal owner 4' does not contain 973" @@ -3092,6 +3255,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1020", name="po_4_race_pi_ff.invalid_text_length", description=( "'Race of principal owner 4: free-form text" @@ -3103,6 +3267,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2003", name="po_4_race_pi_ff.conditional_field_conflict", description=( "When 'race of principal owner 4' does not contain 974" @@ -3122,6 +3287,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_1": [ SBLCheck( is_valid_enum, + id="E1040", name="po_4_gender_flag.invalid_enum_value", description=( "When present, 'sex/gender of principal" @@ -3143,6 +3309,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): SBLCheck.str_length( 0, 300, + id="E1060", name="po_4_gender_ff.invalid_text_length", description=( "'Sex/gender of principal owner 4: free-form" @@ -3154,6 +3321,7 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): "phase_2": [ SBLCheck( has_no_conditional_field_conflict, + id="E2034", name="po_4_gender_ff.conditional_field_conflict", description=( "When 'sex/gender of principal owner 4: NP flag'" @@ -3171,3 +3339,4 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ], }, } + From 45c8e843555d948f9fa195a13ca0a68f4863d8ce Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 04:35:11 -0400 Subject: [PATCH 02/11] addressed linter issues --- src/validator/phase_validations.py | 37 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/validator/phase_validations.py b/src/validator/phase_validations.py index c40cf2d5..a5740c55 100644 --- a/src/validator/phase_validations.py +++ b/src/validator/phase_validations.py @@ -5,23 +5,35 @@ import global_data -from check_functions import (has_correct_length, - has_no_conditional_field_conflict, - has_valid_enum_pair, has_valid_fieldset_pair, - has_valid_format, - has_valid_multi_field_value_count, - has_valid_value_count, is_date, is_date_after, - is_date_before_in_days, is_date_in_range, - is_greater_than, is_greater_than_or_equal_to, - is_less_than, is_number, is_unique_column, - is_unique_in_field, is_valid_code, is_valid_enum, - meets_multi_value_field_restriction, - string_contains) +from check_functions import ( + has_correct_length, + has_no_conditional_field_conflict, + has_valid_enum_pair, + has_valid_fieldset_pair, + has_valid_format, + has_valid_multi_field_value_count, + has_valid_value_count, + is_date, + is_date_after, + is_date_before_in_days, + is_date_in_range, + is_greater_than, + is_greater_than_or_equal_to, + is_less_than, + is_number, + is_unique_column, + is_unique_in_field, + is_valid_code, + is_valid_enum, + meets_multi_value_field_restriction, + string_contains, +) from checks import SBLCheck # read and populate global naics code (this should be called only once) global_data.read_naics_codes() + def get_phase_1_and_2_validations_for_lei(lei: str = None): return { "uid": { @@ -3339,4 +3351,3 @@ def get_phase_1_and_2_validations_for_lei(lei: str = None): ], }, } - From 110720b621d5fbb67a6af92fc0673f2c9a0b6384 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 09:37:52 -0400 Subject: [PATCH 03/11] reformatted --- src/validator/checks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/validator/checks.py b/src/validator/checks.py index 0744f629..633e8833 100644 --- a/src/validator/checks.py +++ b/src/validator/checks.py @@ -73,4 +73,3 @@ def __init__( def get_backend(cls, check_obj: Any) -> Type[BaseCheckBackend]: """Assume Pandas DataFrame and return PandasCheckBackend""" return PandasCheckBackend - From da950b6ba2ae3e2421ace31d9bd3081414b53226 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 10:41:08 -0400 Subject: [PATCH 04/11] added unit test --- src/tests/test_check_functions.py | 63 +++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/src/tests/test_check_functions.py b/src/tests/test_check_functions.py index e40caeef..bb8d71fe 100644 --- a/src/tests/test_check_functions.py +++ b/src/tests/test_check_functions.py @@ -1,26 +1,21 @@ import pandas as pd +import pytest from validator import global_data -from validator.check_functions import ( - has_correct_length, - has_no_conditional_field_conflict, - has_valid_enum_pair, - has_valid_fieldset_pair, - has_valid_format, - has_valid_multi_field_value_count, - has_valid_value_count, - is_date, - is_greater_than, - is_greater_than_or_equal_to, - is_less_than, - is_number, - is_unique_column, - is_unique_in_field, - is_valid_code, - is_valid_enum, - meets_multi_value_field_restriction, - string_contains, -) +from validator.check_functions import (has_correct_length, + has_no_conditional_field_conflict, + has_valid_enum_pair, + has_valid_fieldset_pair, + has_valid_format, + has_valid_multi_field_value_count, + has_valid_value_count, is_date, + is_greater_than, + is_greater_than_or_equal_to, + is_less_than, is_number, + is_unique_column, is_unique_in_field, + is_valid_code, is_valid_enum, + meets_multi_value_field_restriction, + string_contains) class TestInvalidDateFormat: @@ -868,3 +863,31 @@ def test_with_incorrect_values(self): ) is False ) + + class TestSBLCheck: + import pytest + +from validator.checks import SBLCheck + + +class TestSBLCheck: + def test_no_id_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, warning=True, name="Just a Warning") + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + + def test_no_name_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, id="00000", warning=True) + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + def test_name_and_id_check(self): + raised = False + try: + SBLCheck(lambda: True, id="00000", warning=True, name="Just a Warning") + except: + raised = True + assert raised == False From 44612d8bb0af7002cf6bb8e3f7bdaa5137de0ad4 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 11:07:51 -0400 Subject: [PATCH 05/11] fixed linter issues --- src/tests/test_check_functions.py | 45 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/tests/test_check_functions.py b/src/tests/test_check_functions.py index bb8d71fe..b39a631b 100644 --- a/src/tests/test_check_functions.py +++ b/src/tests/test_check_functions.py @@ -2,20 +2,27 @@ import pytest from validator import global_data -from validator.check_functions import (has_correct_length, - has_no_conditional_field_conflict, - has_valid_enum_pair, - has_valid_fieldset_pair, - has_valid_format, - has_valid_multi_field_value_count, - has_valid_value_count, is_date, - is_greater_than, - is_greater_than_or_equal_to, - is_less_than, is_number, - is_unique_column, is_unique_in_field, - is_valid_code, is_valid_enum, - meets_multi_value_field_restriction, - string_contains) +from validator.check_functions import ( + has_correct_length, + has_no_conditional_field_conflict, + has_valid_enum_pair, + has_valid_fieldset_pair, + has_valid_format, + has_valid_multi_field_value_count, + has_valid_value_count, + is_date, + is_greater_than, + is_greater_than_or_equal_to, + is_less_than, + is_number, + is_unique_column, + is_unique_in_field, + is_valid_code, + is_valid_enum, + meets_multi_value_field_restriction, + string_contains, +) +from validator.checks import SBLCheck class TestInvalidDateFormat: @@ -864,11 +871,6 @@ def test_with_incorrect_values(self): is False ) - class TestSBLCheck: - import pytest - -from validator.checks import SBLCheck - class TestSBLCheck: def test_no_id_check(self): @@ -884,10 +886,11 @@ def test_no_name_check(self): assert "Each check must be assigned a `name` and an `id`." in str(exc.value) assert exc.type == ValueError + def test_name_and_id_check(self): raised = False try: SBLCheck(lambda: True, id="00000", warning=True, name="Just a Warning") - except: + except ValueError: raised = True - assert raised == False + assert raised is False From 8285ca556a1a13d70ef720fe35953e94b8525d46 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 11:34:59 -0400 Subject: [PATCH 06/11] addressed the comment --- src/tests/test_checks.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/tests/test_checks.py diff --git a/src/tests/test_checks.py b/src/tests/test_checks.py new file mode 100644 index 00000000..bac4cc75 --- /dev/null +++ b/src/tests/test_checks.py @@ -0,0 +1,27 @@ +import pytest + +from validator.checks import SBLCheck + + +class TestSBLCheck: + def test_no_id_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, warning=True, name="Just a Warning") + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + + def test_no_name_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, id="00000", warning=True) + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + + def test_name_and_id_check(self): + raised = False + try: + SBLCheck(lambda: True, id="00000", warning=True, name="Just a Warning") + except ValueError: + raised = True + assert raised is False From 073db362947960ba1439226b4ee1a2ee0606cd06 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 14:43:08 -0400 Subject: [PATCH 07/11] addressed the comments --- src/tests/test_check_functions.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/tests/test_check_functions.py b/src/tests/test_check_functions.py index b39a631b..e40caeef 100644 --- a/src/tests/test_check_functions.py +++ b/src/tests/test_check_functions.py @@ -1,5 +1,4 @@ import pandas as pd -import pytest from validator import global_data from validator.check_functions import ( @@ -22,7 +21,6 @@ meets_multi_value_field_restriction, string_contains, ) -from validator.checks import SBLCheck class TestInvalidDateFormat: @@ -870,27 +868,3 @@ def test_with_incorrect_values(self): ) is False ) - - -class TestSBLCheck: - def test_no_id_check(self): - with pytest.raises(Exception) as exc: - SBLCheck(lambda: True, warning=True, name="Just a Warning") - - assert "Each check must be assigned a `name` and an `id`." in str(exc.value) - assert exc.type == ValueError - - def test_no_name_check(self): - with pytest.raises(Exception) as exc: - SBLCheck(lambda: True, id="00000", warning=True) - - assert "Each check must be assigned a `name` and an `id`." in str(exc.value) - assert exc.type == ValueError - - def test_name_and_id_check(self): - raised = False - try: - SBLCheck(lambda: True, id="00000", warning=True, name="Just a Warning") - except ValueError: - raised = True - assert raised is False From 1d61e97d88cfede418557c45b110da690efe16d0 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 15:13:24 -0400 Subject: [PATCH 08/11] addressed the comment --- src/validator/checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validator/checks.py b/src/validator/checks.py index 633e8833..5a6777e9 100644 --- a/src/validator/checks.py +++ b/src/validator/checks.py @@ -14,7 +14,7 @@ name="Just a Warning" ) - error_check_implied = SBLCheck(lambda: True name="Error Check") + error_check_implied = SBLCheck(lambda: True, name="Error Check") error_check_explicit = SBLCheck( lambda: True, From d70de1b3431d11732b5de943db39fee57ad9aeca Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 16:01:51 -0400 Subject: [PATCH 09/11] added print --- src/validator/create_schemas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/validator/create_schemas.py b/src/validator/create_schemas.py index e75123fe..d32366cb 100644 --- a/src/validator/create_schemas.py +++ b/src/validator/create_schemas.py @@ -39,8 +39,10 @@ def print_schema_errors(errors: SchemaErrors, phase: str): # this is just a string that we'd need to parse manually check_output = schema_error.args[0] - f"{phase} Validation `{check_name}` with id: `{check_id}` \ + print( + f"{phase} Validation `{check_name}` with id: `{check_id}` \ failed for column `{column_name}`" + ) print(check_output) print("") From d91e13a21334f5392a7a79a82c183ec0675e5564 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 16:19:32 -0400 Subject: [PATCH 10/11] addressed last comment --- src/validator/create_schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validator/create_schemas.py b/src/validator/create_schemas.py index d32366cb..2de71a6c 100644 --- a/src/validator/create_schemas.py +++ b/src/validator/create_schemas.py @@ -40,8 +40,8 @@ def print_schema_errors(errors: SchemaErrors, phase: str): check_output = schema_error.args[0] print( - f"{phase} Validation `{check_name}` with id: `{check_id}` \ - failed for column `{column_name}`" + f"{phase} Validation `{check_name}` with id: `{check_id}` " + "failed for column `{column_name}`" ) print(check_output) print("") From 45ced7dd29dc97f0fee0c634b2c3ff0d78721ca7 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Tue, 12 Sep 2023 16:24:22 -0400 Subject: [PATCH 11/11] fixed linter issue --- src/validator/create_schemas.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/validator/create_schemas.py b/src/validator/create_schemas.py index 2de71a6c..1312f3f7 100644 --- a/src/validator/create_schemas.py +++ b/src/validator/create_schemas.py @@ -24,7 +24,6 @@ def print_schema_errors(errors: SchemaErrors, phase: str): for error in errors.schema_errors: # Name of the column in the dataframe being checked schema_error = error["error"] - column_name = schema_error.schema.name check_id = "n/a" # built in checks such as unique=True are different than custom