I have to take an input in rpc only in one previous input is taken. For Example if we input value for field a then value for field b is compulsory.
I am new to it, I tried giving mandatory true for the last value.
I have to take an input in rpc only in one previous input is taken. For Example if we input value for field a then value for field b is compulsory.
I am new to it, I tried giving mandatory true for the last value.
To have a second parameter become conditionally mandatory based on the first parameter, use
when
andmandatory
at the same time.The
when "../first";
condition, which is defined forleaf second
says something like: "in a valid rpc instance document, leaf 'second' may only appear if leaf 'first' exists". If you add themandatory true
toleaf second
, this becomes: "in a valid rpc instance document, leaf 'second' must appear if leaf 'first' exists."Note that
leaf first
is optional in my example.rpc foo
may only be sent without parameters or with both parameters at the same time.Why does it work that way?
RFC 7950, Section 7.14.2 describes how
input
definitions work:Section 8 of the same RFC describes how constraints such as
when
andmandatory
are applied - thewhen
condition takes precedence: