Custom Parameter Visibility Rule Conditions

Hi,

we are currently trying to extend the knime.extension.Condition with a IsNotEmpty class, which should check if a value of a Parameter in a ParameterGroup is not empty.

However, we are not quite sure how the to_dict method works. The predefined OneOf condition returns a dict with a oneOf key and a list of {"const": value} pairs. But how is that used?

Thank you!

1 Like

The to_dict method currently has to return a JSONForms schema compatible dictionary which is used as JSONForms rule body. So if you want to make sure a field is not empty you could come up with the appropriate JSONForms rule.

Unfortunately JSONForms rules are not super well documented, so I can’t tell you from the top of my head how an notEmpty condition could be implemented.

Hope that helps

2 Likes

Hi @graudata,
if you do not want to dive deep into the JSON Forms (and possibly our Node dialog implementation of it), could you just reverse the effect and use the OneOf rule with [""]?

If you want to dive deep here are some links:

3 Likes

Hi @carstenhaubold, @bwilhelm,

thank you for the fast response!

Yes the OneOf with [""] and a negation works. Unfortunately it raises the error ValueError: Can't find scope for parameter if returning [self._subject.my_input] as a subjects list, for example (as it is a parameter group). That is probably intended and what you mentioned in the documentation where “rules can only depend on parameters on the same level, not in a child or parent parameter group” ?

Nvm, solved it :+1:

For anyone who might come across this using a group parameter:

"properties": {
    "my_input": {
        "not": {
            "const": ""
        }
    }
}

did the trick for me, while returning [self._subject].

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.