MCPcopy Create free account
hub / github.com/WainWong/ComfyUI-Loop-image / validate_inputs

Function validate_inputs

tools.py:35–48  ·  view source on GitHub ↗
(input_types)

Source from the content-addressed store, hash-verified

33 raise NotImplementedError("VariantSupport does not support VALIDATE_INPUTS yet")
34 else:
35 def validate_inputs(input_types):
36 inputs = cls.INPUT_TYPES()
37 for key, value in input_types.items():
38 if isinstance(value, SmartType):
39 continue
40 if "required" in inputs and key in inputs["required"]:
41 expected_type = inputs["required"][key][0]
42 elif "optional" in inputs and key in inputs["optional"]:
43 expected_type = inputs["optional"][key][0]
44 else:
45 expected_type = None
46 if expected_type is not None and MakeSmartType(value) != expected_type:
47 return f"Invalid type of {key}: {value} (expected {expected_type})"
48 return True
49 setattr(cls, "VALIDATE_INPUTS", validate_inputs)
50 return cls
51 return decorator

Callers

nothing calls this directly

Calls 2

MakeSmartTypeFunction · 0.85
INPUT_TYPESMethod · 0.45

Tested by

no test coverage detected