-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to dissable plugin_types built-in valiadations when using LY_PARSE_ONLY #2169
Comments
You have correctly observed that you cannot separate value validation and storing, the storage is often tailored to the exact value and so must be valid. Maybe describe the use-case with more details, I understand the general idea but to show/hide nodes with |
Ok, in my case I am trying to develop dynamic UI which is driven by YANG schema. Let's consider simple scenario like this:
In the UI, this can be represented as a form with two input fields ( The generation is only done, because I don't have real value from user at that point of time, and I need to have data node, which I can use a starting point to evaluate the xpath expression related to |
Okay, so I am going to assume you really want So, the problem should be reduced to how to evaluate |
Thanks, will definitely look into that. |
It seems to me that you need:
Then, whenever a value in the set of nodes that are required changes (i.e., the user types something into an input box, or they change focus to another input box), you re-evaluate all For this, I don't see the need for storing invalid data values. Am I missing something? Also, I wonder if @bedrich-schindler might have some ideas re this use case. |
Hi,
is there some easy way to disable advanced leaf/leaf-list type validations when using
LY_PARSE_ONLY
flag?Background: I need to somehow evaluate staff like "when" conditions prior I will get valid value from end-user. This is needed for UI layer to effectively hide the field if "when" condition is false. Assumption is that when conditions never needs the value of node itself to evaluate given expression. Of course I can generate random values based on basic types as int8 or string. But the problem will start when I have definitions like this:
For this one, I need to generate value that is not only matching original
inet:ipv4-prefix
, but also other custom patterns. So generating value which matches all the patterns is very problematic.So far I have looked into the code and it seems that the main problem is that validations are not separated from storing operations. I have tried to rewrite it and split it. That worked for basic types as string. But then I find out that you have special plugins for ietf based types as ip-address, date-and-time... And for these ones, it seems that I cannot really do that easily as almost each of them has other special methods beyond within the
store
function, which are expecting that the basic string length/pattern validation was already completed correctly. So I can move those parts tovalidate
function, but it would mean that ifstore
function will end withLY_EINCOMPLETE
, user must first callvalidate
function prior functions likecompare
will work, which I don't really think is a good idea...The other way around this is to introduce totally new API to create dummy data nodes by temporarily override lysc_type structure in a way that it will replace the ietf types with basic types and set all advanced validations as string patterns to NULL. Once data node is created, put everything back.
The problem is also not just problem of APIs, where I can say flag
LYD_PARSE_ONLY
, but alsolyd_new_*
Do you have any better idea, how to achieve that?
The text was updated successfully, but these errors were encountered: