Settings loader update with basic email check, and on check abort if not valid

In the settings checker, if a regex_clean is set as None then we will abort the script with error
if the regex is not matching

Add regex check for email basic

Also add a regex_constants list with regex entries (not compiled and compiled)
This commit is contained in:
Clemens Schwaighofer
2025-07-14 15:57:19 +09:00
parent 7183d05dd6
commit 6c2637ad34
8 changed files with 79 additions and 16 deletions

View File

@@ -21,3 +21,5 @@ match_source_list=foo,bar
element_a=Static energy
element_b=123.5
element_c=True
email=foo@bar.com,other+bar-fee@domain-com.cp
email_bad=@bar.com

View File

@@ -68,7 +68,28 @@ def main():
"match_source_list": ["split:,", "in:match_target_list"],
}
)
print(f"Load: {config_load} -> {dump_data(config_data)}")
print(f"[{config_load}] Load: {config_load} -> {dump_data(config_data)}")
except ValueError as e:
print(f"Could not load settings: {e}")
try:
config_load = 'TestB'
config_data = sl.load_settings(
config_load,
{
"email": [
"split:,",
"mandatory:yes",
"check:string.email.basic"
],
"email_bad": [
"split:,",
"mandatory:yes",
"check:string.email.basic"
]
}
)
print(f"[{config_load}] Load: {config_load} -> {dump_data(config_data)}")
except ValueError as e:
print(f"Could not load settings: {e}")

View File

@@ -18,7 +18,8 @@ def main():
log_path=script_path.joinpath('log', 'test.log'),
log_name="Test Log",
log_settings={
"log_level_console": 'DEBUG',
# "log_level_console": 'DEBUG',
"log_level_console": None,
"log_level_file": 'DEBUG',
# "console_color_output_enabled": False,
}