libyang
3.4.2
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
|
Data validation is performed implicitly to the input data processed by the parser and on demand via the lyd_validate_*() functions. The explicit validation process is supposed to be used when a (complex or simple) change is done on the data tree (via data manipulation functions) and the data tree is expected to be valid (it doesn't make sense to validate modified result of filtered <get> operation).
Similarly to the data parser, there are individual functions to validate standard data tree (lyd_validate_all()) and RPC, Action and Notification (lyd_validate_op()). For the standard data trees, it is possible to modify the validation process by Data validation options. This way the state data can be prohibited (LYD_VALIDATE_NO_STATE) and checking for mandatory nodes can be limited to the YANG modules with already present data instances (LYD_VALIDATE_PRESENT). Validation of the standard data tree can be also limited with lyd_validate_module() function, which scopes only to a specified single YANG module.
Since the operation data trees (RPCs, Actions or Notifications) can reference (leafref, instance-identifier, when/must expressions) data from a datastore tree, lyd_validate_op() may require additional data tree to be provided. This is a difference in contrast to the parsing process, when the data are loaded from an external source and invalid reference outside the operation tree is acceptable.