libyang icon indicating copy to clipboard operation
libyang copied to clipboard

How can I avoid validating lref/when/must restriction when validating rpc?

Open lyzliyuzhi91 opened this issue 2 years ago • 5 comments

If a rpc input leaf is a lref and it reference to a config or status node, it may be hard to get the value of such config or status node. In libyang1, there is an option to avoid such validation

#define LYD_OPT_NOEXTDEPS  0x8000 /**< Allow external dependencies (external leafrefs, instance-identifiers, must,
                                       and when) to not be resolved/satisfied during validation. */

But it libyang2, I cannot find the alternative option. So how can I do it ?

lyzliyuzhi91 avatar Aug 12 '23 09:08 lyzliyuzhi91

In libyang v1 it was added out of necessity and bad design. Either validate the RPC normally or not at all, nothing else really makes sense.

michalvasko avatar Aug 15 '23 08:08 michalvasko

Fine, but I think such requirement do indeed exist, which depens on the architecture of the concerned softwares. I have a server that receives rpc and then parse and validate it, after that, the server will dispatch the rpc to the apllications which subscribe such rpc. The server does not store any status. In such case, the server is not quit suitable to query the status infomation from applications. So I want to disable the validation for this leafref/when/must which refer to status node out of the rpc.

lyzliyuzhi91 avatar Aug 24 '23 09:08 lyzliyuzhi91

So do not validate it all, like I said.

michalvasko avatar Aug 24 '23 09:08 michalvasko

But I want to validate the "mandatory"🤣

lyzliyuzhi91 avatar Aug 26 '23 09:08 lyzliyuzhi91

What problem would that solve? The only valid information you can have is whether the data are valid or invalid. Validating mandatory will not tell you it is either.

michalvasko avatar Sep 04 '23 07:09 michalvasko