valdiation BUGFIX clear mand flag when trusted data
diff --git a/src/validation.c b/src/validation.c
index ccacde0..83fb6d8 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -340,60 +340,62 @@
schema = node->schema; /* shortcut */
- if (!(options & (LYD_OPT_TRUSTED | LYD_OPT_NOTIF_FILTER)) && (node->validity & LYD_VAL_MAND)) {
- /* check presence and correct order of all keys in case of list */
- if (schema->nodetype == LYS_LIST && !(options & (LYD_OPT_GET | LYD_OPT_GETCONFIG))) {
- if (lyv_keys(node)) {
- return EXIT_FAILURE;
- }
- }
-
- if (schema->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_ANYDATA)) {
- /* check number of instances (similar to list uniqueness) for non-list nodes */
-
- /* find duplicity */
- start = lyd_first_sibling(node);
- for (diter = start; diter; diter = diter->next) {
- if (diter->schema == schema && diter != node) {
- LOGVAL(LYE_TOOMANY, LY_VLOG_LYD, node, schema->name,
- lys_parent(schema) ? lys_parent(schema)->name : "data tree");
+ if (node->validity & LYD_VAL_MAND) {
+ if (!(options & (LYD_OPT_TRUSTED | LYD_OPT_NOTIF_FILTER))) {
+ /* check presence and correct order of all keys in case of list */
+ if (schema->nodetype == LYS_LIST && !(options & (LYD_OPT_GET | LYD_OPT_GETCONFIG))) {
+ if (lyv_keys(node)) {
return EXIT_FAILURE;
}
}
- }
- if (options & LYD_OPT_OBSOLETE) {
- /* status - of the node's schema node itself and all its parents that
- * cannot have their own instance (like a choice statement) */
- siter = node->schema;
- do {
- if (((siter->flags & LYS_STATUS_MASK) == LYS_STATUS_OBSLT) && (options & LYD_OPT_OBSOLETE)) {
- LOGVAL(LYE_OBSDATA, LY_VLOG_LYD, node, schema->name);
- return EXIT_FAILURE;
- }
- siter = lys_parent(siter);
- } while (siter && !(siter->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_ANYDATA)));
+ if (schema->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_ANYDATA)) {
+ /* check number of instances (similar to list uniqueness) for non-list nodes */
- /* status of the identity value */
- if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
- if (options & LYD_OPT_OBSOLETE) {
- /* check that we are not instantiating obsolete type */
- tpdf = ((struct lys_node_leaf *)node->schema)->type.der;
- while (tpdf) {
- if ((tpdf->flags & LYS_STATUS_MASK) == LYS_STATUS_OBSLT) {
- LOGVAL(LYE_OBSTYPE, LY_VLOG_LYD, node, schema->name, tpdf->name);
- return EXIT_FAILURE;
- }
- tpdf = tpdf->type.der;
+ /* find duplicity */
+ start = lyd_first_sibling(node);
+ for (diter = start; diter; diter = diter->next) {
+ if (diter->schema == schema && diter != node) {
+ LOGVAL(LYE_TOOMANY, LY_VLOG_LYD, node, schema->name,
+ lys_parent(schema) ? lys_parent(schema)->name : "data tree");
+ return EXIT_FAILURE;
}
}
- if (((struct lyd_node_leaf_list *)node)->value_type == LY_TYPE_IDENT) {
- ident = ((struct lyd_node_leaf_list *)node)->value.ident;
- if (lyp_check_status(schema->flags, schema->module, schema->name,
- ident->flags, ident->module, ident->name, NULL)) {
- LOGPATH(LY_VLOG_LYD, node);
+ }
+
+ if (options & LYD_OPT_OBSOLETE) {
+ /* status - of the node's schema node itself and all its parents that
+ * cannot have their own instance (like a choice statement) */
+ siter = node->schema;
+ do {
+ if (((siter->flags & LYS_STATUS_MASK) == LYS_STATUS_OBSLT) && (options & LYD_OPT_OBSOLETE)) {
+ LOGVAL(LYE_OBSDATA, LY_VLOG_LYD, node, schema->name);
return EXIT_FAILURE;
}
+ siter = lys_parent(siter);
+ } while (siter && !(siter->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_ANYDATA)));
+
+ /* status of the identity value */
+ if (schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) {
+ if (options & LYD_OPT_OBSOLETE) {
+ /* check that we are not instantiating obsolete type */
+ tpdf = ((struct lys_node_leaf *)node->schema)->type.der;
+ while (tpdf) {
+ if ((tpdf->flags & LYS_STATUS_MASK) == LYS_STATUS_OBSLT) {
+ LOGVAL(LYE_OBSTYPE, LY_VLOG_LYD, node, schema->name, tpdf->name);
+ return EXIT_FAILURE;
+ }
+ tpdf = tpdf->type.der;
+ }
+ }
+ if (((struct lyd_node_leaf_list *)node)->value_type == LY_TYPE_IDENT) {
+ ident = ((struct lyd_node_leaf_list *)node)->value.ident;
+ if (lyp_check_status(schema->flags, schema->module, schema->name,
+ ident->flags, ident->module, ident->name, NULL)) {
+ LOGPATH(LY_VLOG_LYD, node);
+ return EXIT_FAILURE;
+ }
+ }
}
}
}