diff options
author | Christian Breunig <christian@breunig.cc> | 2024-05-27 10:02:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-27 10:02:55 +0200 |
commit | 42b4395551e792aa6994ac61fb3013712e3f90ba (patch) | |
tree | c195b7162f147c20a8635380155ee95431dfcb22 | |
parent | 8c65eb12453f45f7918ced62d7ecbf6905d6bf49 (diff) | |
parent | b7f10478141051908478f7637bb087e70a25c874 (diff) | |
download | vyos1x-config-42b4395551e792aa6994ac61fb3013712e3f90ba.tar.gz vyos1x-config-42b4395551e792aa6994ac61fb3013712e3f90ba.zip |
Merge pull request #28 from vyos/mergify/bp/sagitta/pr-27sagitta
T6404: add constraintGroup element to reference tree (backport #27)
-rw-r--r-- | src/reference_tree.ml | 18 | ||||
-rw-r--r-- | src/reference_tree.mli | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml index 7f6cc25..4889734 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -22,6 +22,7 @@ type completion_help_type = type ref_node_data = { node_type: node_type; constraints: value_constraint list; + constraint_group: value_constraint list; constraint_error_message: string; completion_help: completion_help_type list; help: string; @@ -44,6 +45,7 @@ exception Validation_error of string let default_data = { node_type = Other; constraints = []; + constraint_group = []; constraint_error_message = "Invalid value"; completion_help = []; help = "No help available"; @@ -137,6 +139,21 @@ let load_constraint_from_xml d c = | _ -> raise (Bad_interface_definition "Malformed constraint") in Xml.fold aux d c +let load_constraint_group_from_xml d c = + let aux d c = + match c with + | Xml.Element ("regex", _, [Xml.PCData s]) -> + let cs = (Regex s) :: d.constraint_group in + {d with constraint_group=cs} + | Xml.Element ("validator", [("name", n); ("argument", a)], _) -> + let cs = (External (n, Some a)) :: d.constraint_group in + {d with constraint_group=cs} + | Xml.Element ("validator", [("name", n)], _) -> + let cs = (External (n, None)) :: d.constraint_group in + {d with constraint_group=cs} + | _ -> raise (Bad_interface_definition "Malformed constraint") + in Xml.fold aux d c + let data_from_xml d x = let aux d x = match x with @@ -149,6 +166,7 @@ let data_from_xml d x = | Xml.Element ("constraintErrorMessage", _, [Xml.PCData s]) -> {d with constraint_error_message=s} | Xml.Element ("constraint", _, _) -> load_constraint_from_xml d x + | Xml.Element ("constraintGroup", _, _) -> load_constraint_group_from_xml d x | Xml.Element ("priority", _, [Xml.PCData i]) -> {d with priority=Some i} | Xml.Element ("hidden", _, _) -> {d with hidden=true} diff --git a/src/reference_tree.mli b/src/reference_tree.mli index 0e70ff5..a18d875 100644 --- a/src/reference_tree.mli +++ b/src/reference_tree.mli @@ -17,6 +17,7 @@ type completion_help_type = type ref_node_data = { node_type: node_type; constraints: value_constraint list; + constraint_group: value_constraint list; constraint_error_message: string; completion_help: completion_help_type list; help: string; |