MCPcopy Create free account
hub / github.com/Tong89/smartNode / validate_count_update

Function validate_count_update

backend/schemas.py:73–92  ·  view source on GitHub ↗
(data, lo=None, hi=None)

Source from the content-addressed store, hash-verified

71
72
73def validate_count_update(data, lo=None, hi=None):
74 if not isinstance(data, dict):
75 raise ValidationError([_err("body", "必须为 JSON 对象")])
76
77 errors = []
78 for unknown in set(data.keys()) - {"count"}:
79 errors.append(_err(unknown, "未知字段,已拒绝"))
80
81 c = data.get("count")
82 if not _is_int(c):
83 errors.append(_err("count", "必填,且须为整数"))
84 else:
85 if lo is not None and c < lo:
86 errors.append(_err("count", f"不得小于 {lo}"))
87 if hi is not None and c > hi:
88 errors.append(_err("count", f"不得大于 {hi}"))
89
90 if errors:
91 raise ValidationError(errors)
92 return data

Callers 2

update_ground_stationsFunction · 0.90
update_leo_satellitesFunction · 0.90

Calls 5

ValidationErrorClass · 0.85
_errFunction · 0.85
_is_intFunction · 0.85
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected