mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-19 11:03:00 +08:00
Support validation of inputs and outputs
This commit is contained in:
parent
676de9e618
commit
68153f6c04
@ -150,6 +150,9 @@ class _IO_V3:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def validate(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def io_type(self):
|
||||
return self.Parent.io_type
|
||||
@ -899,6 +902,12 @@ class DynamicCombo(ComfyTypeI):
|
||||
"options": [o.as_dict() for o in self.options],
|
||||
})
|
||||
|
||||
def validate(self):
|
||||
# make sure all nested inputs are validated
|
||||
for option in self.options:
|
||||
for input in option.inputs:
|
||||
input.validate()
|
||||
|
||||
@comfytype(io_type="COMFY_MATCHTYPE_V3")
|
||||
class MatchType(ComfyTypeIO):
|
||||
class Template:
|
||||
@ -1105,6 +1114,11 @@ class Schema:
|
||||
issues.append(f"Ids must be unique between inputs and outputs, but {intersection} are not.")
|
||||
if len(issues) > 0:
|
||||
raise ValueError("\n".join(issues))
|
||||
# validate inputs and outputs
|
||||
for input in self.inputs:
|
||||
input.validate()
|
||||
for output in self.outputs:
|
||||
output.validate()
|
||||
|
||||
def finalize(self):
|
||||
"""Add hidden based on selected schema options, and give outputs without ids default ids."""
|
||||
@ -1697,6 +1711,7 @@ __all__ = [
|
||||
"MultiType",
|
||||
# Dynamic Types
|
||||
"MatchType",
|
||||
"DynamicCombo",
|
||||
# Other classes
|
||||
"HiddenHolder",
|
||||
"Hidden",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user