Skip to content

Commit 7761939

Browse files
committed
validate: add storage_options_gb integer range check
Reject non-integer or <1 GB values in storage_options_gb so the GSMArena tablet/watch import is validated against a sane range (mirrors the field the imported records populate). Refs #1
1 parent 2aa4302 commit 7761939

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/validate.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ def _check_source_urls(name: str, record: dict[str, Any], errors: list[str]) ->
148148
errors.append(f"{name}: source_urls must be a non-empty list of http(s) URL strings")
149149

150150

151+
def _check_storage_options_gb(name: str, record: dict[str, Any], errors: list[str]) -> None:
152+
values = record.get("storage_options_gb")
153+
if values is None:
154+
return
155+
if not isinstance(values, list):
156+
errors.append(f"{name}: storage_options_gb must be a list of integer GB values")
157+
return
158+
bad = [value for value in values if not isinstance(value, int) or value < 1]
159+
if bad:
160+
errors.append(f"{name}: storage_options_gb contains invalid integer GB values {bad}")
161+
162+
151163
def _check_variant_path(
152164
fname: str,
153165
rec: dict[str, Any],
@@ -285,6 +297,7 @@ def validate() -> list[str]:
285297
errors.append(f"{fname}: brand '{rec.get('brand')}' not a known brand")
286298
if rec.get("soc") is not None and rec.get("soc") not in soc_slugs:
287299
errors.append(f"{fname}: soc '{rec.get('soc')}' not a known SoC")
300+
_check_storage_options_gb(fname, rec, errors)
288301
_check_variant_path(fname, rec, category, errors)
289302

290303
for fname, rec in gpus:

0 commit comments

Comments
 (0)