fix: 执行 null 参数的类型和枚举校验

This commit is contained in:
Shuhan Si authored and Xubin Ren committed 2026-10-03 20:03:48 +08:00
1 parent 0848565067
commit 9ea3268dfb
2 files changed
+34

No files matched your search

+4
View File
@@ -76,7 +76,11 @@ class Schema(ABC):
t = Schema.resolve_json_schema_type(raw_type)
if nullable and val is None:
if "enum" in schema and val not in schema["enum"]:
return [f"{label} must be one of {schema['enum']}"]
return []
if (raw_type == "null" or raw_type == ["null"]) and val is not None:
return [f"{label} should be null"]
if isinstance(raw_type, list):
types = [item for item in cast(list[Any], raw_type) if item != "null"]
if len(types) > 1: