fix(tools): separate null-only guard from union validation
This commit is contained in:
1 parent
9ea3268dfb
commit
e3fc2a7c7a
1 file changed
+2
-2
@@ -75,12 +75,12 @@ class Schema(ABC):
|
||||
nullable = (isinstance(raw_type, list) and "null" in raw_type) or schema.get("nullable", False)
|
||||
t = Schema.resolve_json_schema_type(raw_type)
|
||||
|
||||
if (raw_type == "null" or raw_type == ["null"]) and val is not None:
|
||||
return [f"{label} should be null"]
|
||||
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:
|
||||
|
||||
Reference in new issue
Block a user