Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa2fbd4f70 | ||
|
|
58c8447531 | ||
|
|
bcca43d774 |
@@ -1,7 +1,7 @@
|
|||||||
# MARK: Project info
|
# MARK: Project info
|
||||||
[project]
|
[project]
|
||||||
name = "corelibs"
|
name = "corelibs"
|
||||||
version = "0.12.0"
|
version = "0.12.2"
|
||||||
description = "Collection of utils for Python scripts"
|
description = "Collection of utils for Python scripts"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
|
|||||||
@@ -175,7 +175,9 @@ class SettingsLoader:
|
|||||||
# - length: for string length
|
# - length: for string length
|
||||||
# - range: for int/float range check
|
# - range: for int/float range check
|
||||||
# mandatory check
|
# mandatory check
|
||||||
if check == "mandatory:yes" and not settings[config_id].get(entry):
|
if check == "mandatory:yes" and (
|
||||||
|
not settings[config_id].get(entry) or settings[config_id].get(entry) == ['']
|
||||||
|
):
|
||||||
error = True
|
error = True
|
||||||
self.__print(f"[!] Missing content entry for: {entry}", 'ERROR')
|
self.__print(f"[!] Missing content entry for: {entry}", 'ERROR')
|
||||||
# skip if empty none
|
# skip if empty none
|
||||||
@@ -392,7 +394,8 @@ class SettingsLoader:
|
|||||||
clean: re.Pattern[str] | None = None
|
clean: re.Pattern[str] | None = None
|
||||||
if regex_clean is not None:
|
if regex_clean is not None:
|
||||||
clean = re.compile(regex_clean, re.VERBOSE)
|
clean = re.compile(regex_clean, re.VERBOSE)
|
||||||
if not check.search(value):
|
# value must be set if clean is None, else empty value is allowed and will fail
|
||||||
|
if (clean is None and value or clean) and not check.search(value):
|
||||||
self.__print(
|
self.__print(
|
||||||
f"[!] Invalid content for '{entry}' with check '{validate}' and data: {value}",
|
f"[!] Invalid content for '{entry}' with check '{validate}' and data: {value}",
|
||||||
'ERROR', print_error
|
'ERROR', print_error
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[TestA]
|
[TestA]
|
||||||
foo=bar
|
foo=bar
|
||||||
foobar=1
|
foobar=1
|
||||||
|
bar=st
|
||||||
some_match=foo
|
some_match=foo
|
||||||
some_match_list=foo,bar
|
some_match_list=foo,bar
|
||||||
test_list=a,b,c,d f, g h
|
test_list=a,b,c,d f, g h
|
||||||
@@ -21,5 +22,6 @@ match_source_list=foo,bar
|
|||||||
element_a=Static energy
|
element_a=Static energy
|
||||||
element_b=123.5
|
element_b=123.5
|
||||||
element_c=True
|
element_c=True
|
||||||
email=foo@bar.com,other+bar-fee@domain-com.cp
|
email=foo@bar.com,other+bar-fee@domain-com.cp,
|
||||||
email_bad=@bar.com
|
email_not_mandatory=
|
||||||
|
email_bad=gii@bar.com
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ def main():
|
|||||||
{
|
{
|
||||||
"foo": ["mandatory:yes"],
|
"foo": ["mandatory:yes"],
|
||||||
"foobar": ["check:int"],
|
"foobar": ["check:int"],
|
||||||
|
"bar": ["mandatory:yes"],
|
||||||
"some_match": ["matching:foo|bar"],
|
"some_match": ["matching:foo|bar"],
|
||||||
"some_match_list": ["split:,", "matching:foo|bar"],
|
"some_match_list": ["split:,", "matching:foo|bar"],
|
||||||
"test_list": [
|
"test_list": [
|
||||||
@@ -82,6 +83,11 @@ def main():
|
|||||||
"mandatory:yes",
|
"mandatory:yes",
|
||||||
"check:string.email.basic"
|
"check:string.email.basic"
|
||||||
],
|
],
|
||||||
|
"email_not_mandatory": [
|
||||||
|
"split:,",
|
||||||
|
# "mandatory:yes",
|
||||||
|
"check:string.email.basic"
|
||||||
|
],
|
||||||
"email_bad": [
|
"email_bad": [
|
||||||
"split:,",
|
"split:,",
|
||||||
"mandatory:yes",
|
"mandatory:yes",
|
||||||
|
|||||||
Reference in New Issue
Block a user