def from_dict(cls, *, plug_dict: Dict[str, str], plug_name: str) -> "ContentPlug": interface = plug_dict.get("interface") if interface != "content": raise PlugValidationError( plug_name=plug_name, message="`interface={}` is invalid for content slot".format(interface), ) target = plug_dict.get("target", None) if target is None: raise PlugValidationError( plug_name=plug_name, message="`target` is required for content slot" ) return ContentPlug( plug_name=plug_name, content=plug_dict.get("content", None), target=target, default_provider=plug_dict.get("default-provider", None), )
def validate(self) -> None: if not self.target: raise PlugValidationError( plug_name=self.plug_name, message="`target` is required for content slot", )