diff --git a/cffi/cdefs.h b/cffi/cdefs.h
index 0e4bd97f..ba6bd5d4 100644
--- a/cffi/cdefs.h
+++ b/cffi/cdefs.h
@@ -314,6 +314,7 @@ LY_ERR lyd_print_all(struct ly_out *, const struct lyd_node *, LYD_FORMAT, uint3
#define LYD_VALIDATE_NO_STATE ...
#define LYD_VALIDATE_PRESENT ...
#define LYD_VALIDATE_OPTS_MASK ...
+#define LYD_VALIDATE_MULTI_ERROR ...
LY_ERR lyd_parse_data_mem(const struct ly_ctx *, const char *, LYD_FORMAT, uint32_t, uint32_t, struct lyd_node **);
diff --git a/libyang/context.py b/libyang/context.py
index dc3e0052..eefc4e05 100644
--- a/libyang/context.py
+++ b/libyang/context.py
@@ -339,6 +339,7 @@ def parse_data(
ordered: bool = False,
strict: bool = False,
validate_present: bool = False,
+ validate_multi_error: bool = False,
) -> Optional[DNode]:
if self.cdata is None:
raise RuntimeError("context already destroyed")
@@ -351,7 +352,9 @@ def parse_data(
strict=strict,
)
validation_flgs = validation_flags(
- no_state=no_state, validate_present=validate_present
+ no_state=no_state,
+ validate_present=validate_present,
+ validate_multi_error=validate_multi_error,
)
fmt = data_format(fmt)
encode = True
@@ -403,6 +406,7 @@ def parse_data_mem(
ordered: bool = False,
strict: bool = False,
validate_present: bool = False,
+ validate_multi_error: bool = False,
) -> Optional[DNode]:
return self.parse_data(
fmt,
@@ -416,6 +420,7 @@ def parse_data_mem(
ordered=ordered,
strict=strict,
validate_present=validate_present,
+ validate_multi_error=validate_multi_error,
)
def parse_data_file(
@@ -430,6 +435,7 @@ def parse_data_file(
ordered: bool = False,
strict: bool = False,
validate_present: bool = False,
+ validate_multi_error: bool = False,
) -> Optional[DNode]:
return self.parse_data(
fmt,
@@ -443,6 +449,7 @@ def parse_data_file(
ordered=ordered,
strict=strict,
validate_present=validate_present,
+ validate_multi_error=validate_multi_error,
)
def __iter__(self) -> Iterator[Module]:
diff --git a/libyang/data.py b/libyang/data.py
index 0ed18750..c2bf95f5 100644
--- a/libyang/data.py
+++ b/libyang/data.py
@@ -171,12 +171,15 @@ def data_type(dtype):
def validation_flags(
no_state: bool = False,
validate_present: bool = False,
+ validate_multi_error: bool = False,
) -> int:
flags = 0
if no_state:
flags |= lib.LYD_VALIDATE_NO_STATE
if validate_present:
flags |= lib.LYD_VALIDATE_PRESENT
+ if validate_multi_error:
+ flags |= lib.LYD_VALIDATE_MULTI_ERROR
return flags
diff --git a/tests/test_data.py b/tests/test_data.py
index 84e68f82..25bec67d 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -256,6 +256,31 @@ def test_data_parse_config_xml(self):
finally:
dnode.free()
+ XML_CONFIG_MULTI_ERROR = """
+ foo
+
+ https
+ /CESNET/libyang-python
+ abcd
+
+ 2000
+
+"""
+
+ def test_data_parse_config_xml_multi_error(self):
+ with self.assertRaises(Exception) as cm:
+ self.ctx.parse_data_mem(
+ self.XML_CONFIG_MULTI_ERROR,
+ "xml",
+ validate_present=True,
+ validate_multi_error=True,
+ )
+ self.assertEqual(
+ str(cm.exception),
+ 'failed to parse data tree: Invalid boolean value "abcd".: '
+ 'List instance is missing its key "host".',
+ )
+
XML_STATE = """
foo