diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-12-12 20:19:16 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-12-17 21:13:45 -0600 |
| commit | 52b0ff3942ce984a0b65e73b109fe05837323efb (patch) | |
| tree | c53cb7d4ac25767320fe11dc5497a2bc102f023a /src/reference_tree.ml | |
| parent | ebc3e8804c612d7b1cdd260adc5e9930505bcdd6 (diff) | |
| download | vyos1x-config-52b0ff3942ce984a0b65e73b109fe05837323efb.tar.gz vyos1x-config-52b0ff3942ce984a0b65e73b109fe05837323efb.zip | |
T8061: simplify allowed_edit_node with path_type
Diffstat (limited to 'src/reference_tree.ml')
| -rw-r--r-- | src/reference_tree.ml | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml index 82604f4..c78529e 100644 --- a/src/reference_tree.ml +++ b/src/reference_tree.ml @@ -742,30 +742,21 @@ let get_path_type_str ?(legacy_format=false) rtree cpath = assuming that it is (1) a valid path of the reference tree (2) neither a tag nor leaf node - To confirm (2) in the case of a tag node, one has to allow for a - 'potential' tag value as final element of the path. *) let allowed_edit_level rtree path = if Util.is_empty path then Error {|The "edit" command cannot be issued at an empty path|} else - let refp = refpath rtree path - in - if Util.is_empty refp then + match get_path_type rtree path with + | `Invalid -> Error {|The "edit" command cannot be issued at a non-existent path of the reference tree|} - else - if is_tag rtree refp && not (potential_tag_value rtree path) - then + | `Tag -> Error {|The "edit" command cannot be issued at the level of tag node|} - else - if potential_leaf_value rtree path - then - Error {|The "edit" command cannot be issued at the level of leaf value|} - else - if is_leaf rtree refp - then + | `Leaf -> Error {|The "edit" command cannot be issued at the level of leaf node|} - else Ok () + | `Leaf_value -> + Error {|The "edit" command cannot be issued at the level of leaf value|} + | _ -> Ok () let get_ceil_data f reftree path = (* raises: |
