Development
This commit is contained in:
parent
7270ca7f28
commit
89306b132d
1 changed files with 3 additions and 3 deletions
|
|
@ -502,11 +502,11 @@ def validate_config(data):
|
||||||
for idx, bl in enumerate(data.get("dns_blocking", {}).get("blocklists", [])):
|
for idx, bl in enumerate(data.get("dns_blocking", {}).get("blocklists", [])):
|
||||||
name = bl.get("name", "")
|
name = bl.get("name", "")
|
||||||
label = f"dns_blocking.blocklists[{idx}] '{name}'"
|
label = f"dns_blocking.blocklists[{idx}] '{name}'"
|
||||||
for field in ("name", "description", "save_as", "url", "format"):
|
bl_type = bl.get("bl_type", "community")
|
||||||
|
required = ("name", "description", "save_as") + (() if bl_type == "local" else ("url",))
|
||||||
|
for field in required:
|
||||||
if not bl.get(field):
|
if not bl.get(field):
|
||||||
errors.append(f"{label}: missing or empty field '{field}'.")
|
errors.append(f"{label}: missing or empty field '{field}'.")
|
||||||
if bl.get("format") and bl["format"] not in VALID_BLOCKLIST_FORMATS:
|
|
||||||
errors.append(f"{label}: format must be one of: {', '.join(sorted(VALID_BLOCKLIST_FORMATS))}.")
|
|
||||||
if name:
|
if name:
|
||||||
err = check_blocklist_name_unique(
|
err = check_blocklist_name_unique(
|
||||||
data.get("dns_blocking", {}).get("blocklists", []), name, exclude_idx=idx
|
data.get("dns_blocking", {}).get("blocklists", []), name, exclude_idx=idx
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue