Skip to content

Commit ff3cd62

Browse files
committed
validation BUGFIX multi-error when dependencies
Fixes #2516
1 parent 2d34826 commit ff3cd62

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/validation.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,12 +1007,13 @@ lyd_validate_new(struct lyd_node **first, const struct lysc_node *sparent, const
10071007
* @param[in] first First data sibling of the non-existing node.
10081008
* @param[in] parent Data parent of the non-existing node.
10091009
* @param[in] snode Schema node of the non-existing node.
1010+
* @param[in] val_opts Validation options.
10101011
* @param[out] disabled First when that evaluated false, if any.
10111012
* @return LY_ERR value.
10121013
*/
10131014
static LY_ERR
10141015
lyd_validate_dummy_when(const struct lyd_node *first, const struct lyd_node *parent, const struct lysc_node *snode,
1015-
const struct lysc_when **disabled)
1016+
uint32_t val_opts, const struct lysc_when **disabled)
10161017
{
10171018
LY_ERR rc = LY_SUCCESS;
10181019
struct lyd_node *tree, *dummy = NULL;
@@ -1053,6 +1054,11 @@ lyd_validate_dummy_when(const struct lyd_node *first, const struct lyd_node *par
10531054

10541055
/* evaluate all when */
10551056
rc = lyd_validate_node_when(tree, dummy, snode, xp_opts, disabled);
1057+
if ((rc == LY_EINCOMPLETE) && (val_opts & LYD_VALIDATE_MULTI_ERROR)) {
1058+
/* cannot evaluate properly, just ignore */
1059+
rc = LY_SUCCESS;
1060+
}
1061+
10561062
if (rc == LY_EINCOMPLETE) {
10571063
/* all other when must be resolved by now */
10581064
LOGINT(snode->module->ctx);
@@ -1100,7 +1106,7 @@ lyd_validate_mandatory(const struct lyd_node *first, const struct lyd_node *pare
11001106
disabled = NULL;
11011107
if (lysc_has_when(snode)) {
11021108
/* if there are any when conditions, they must be true for a validation error */
1103-
LY_CHECK_RET(lyd_validate_dummy_when(first, parent, snode, &disabled));
1109+
LY_CHECK_RET(lyd_validate_dummy_when(first, parent, snode, val_opts, &disabled));
11041110
}
11051111

11061112
if (!disabled) {
@@ -1177,7 +1183,7 @@ lyd_validate_minmax(const struct lyd_node *first, const struct lyd_node *parent,
11771183
disabled = NULL;
11781184
if (lysc_has_when(snode)) {
11791185
/* if there are any when conditions, they must be true for a validation error */
1180-
LY_CHECK_RET(lyd_validate_dummy_when(first, parent, snode, &disabled));
1186+
LY_CHECK_RET(lyd_validate_dummy_when(first, parent, snode, val_opts, &disabled));
11811187
}
11821188

11831189
if (disabled) {

0 commit comments

Comments
 (0)