diff options
| author | Daniil Baturin <daniil@baturin.org> | 2025-09-26 14:45:30 +0100 |
|---|---|---|
| committer | Daniil Baturin <daniil@baturin.org> | 2025-09-26 14:45:30 +0100 |
| commit | 28a605928daa951ea140bb3d30258508d00450e5 (patch) | |
| tree | 3263d5afbadd83016801357d658bad98fbeaf2e6 /schema | |
| parent | 06e491caf2fdd8b4e2fe5f3b4396680fca61eeab (diff) | |
| download | vyos-1x-28a605928daa951ea140bb3d30258508d00450e5.tar.gz vyos-1x-28a605928daa951ea140bb3d30258508d00450e5.zip | |
op-mode: T7871: add support for op mode command argument constraints
Diffstat (limited to 'schema')
| -rw-r--r-- | schema/interface_definition.rng | 8 | ||||
| -rw-r--r-- | schema/op-mode-definition.rnc | 23 | ||||
| -rw-r--r-- | schema/op-mode-definition.rng | 45 |
3 files changed, 63 insertions, 13 deletions
diff --git a/schema/interface_definition.rng b/schema/interface_definition.rng index d653d1b01..f36d95eed 100644 --- a/schema/interface_definition.rng +++ b/schema/interface_definition.rng @@ -2,19 +2,19 @@ <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <!-- interface_definition.rnc: VyConf reference tree XML grammar - + Copyright VyOS maintainers and contributors <maintainers@vyos.io> - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 diff --git a/schema/op-mode-definition.rnc b/schema/op-mode-definition.rnc index c10cf0431..4dc2592c0 100644 --- a/schema/op-mode-definition.rnc +++ b/schema/op-mode-definition.rnc @@ -89,12 +89,12 @@ children = element children # Nodes may have properties # For simplicity, any property is allowed in any node, # but whether they are used or not is implementation-defined - - properties = element properties { help? & - completionHelp* + completionHelp* & + constraint? & + (element constraintErrorMessage { text })? } # All nodes must have "name" attribute @@ -103,9 +103,22 @@ nodeNameAttr = attribute name text } +# Tag and leaf nodes may have constraints on their names and values +# (respectively). +# When multiple constraints are listed, they work as logical OR +constraint = element constraint +{ + ( (element regex { text }) | + validator )+ +} - - +# A constraint may also use an external validator rather than regex +validator = element validator +{ + ( (attribute name { text }) & + (attribute argument { text })? ), + empty +} # help tags contains brief description of the purpose of the node help = element help diff --git a/schema/op-mode-definition.rng b/schema/op-mode-definition.rng index 692584fb4..ec2a4c649 100644 --- a/schema/op-mode-definition.rng +++ b/schema/op-mode-definition.rng @@ -2,19 +2,19 @@ <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <!-- interface_definition.rnc: VyConf reference tree XML grammar - + Copyright VyOS maintainers and contributors <maintainers@vyos.io> - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 @@ -178,6 +178,14 @@ <zeroOrMore> <ref name="completionHelp"/> </zeroOrMore> + <optional> + <ref name="constraint"/> + </optional> + <optional> + <element name="constraintErrorMessage"> + <text/> + </element> + </optional> </interleave> </element> </define> @@ -185,6 +193,35 @@ <define name="nodeNameAttr"> <attribute name="name"/> </define> + <!-- + Tag and leaf nodes may have constraints on their names and values + (respectively). + When multiple constraints are listed, they work as logical OR + --> + <define name="constraint"> + <element name="constraint"> + <oneOrMore> + <choice> + <element name="regex"> + <text/> + </element> + <ref name="validator"/> + </choice> + </oneOrMore> + </element> + </define> + <!-- A constraint may also use an external validator rather than regex --> + <define name="validator"> + <element name="validator"> + <interleave> + <attribute name="name"/> + <optional> + <attribute name="argument"/> + </optional> + </interleave> + <empty/> + </element> + </define> <!-- help tags contains brief description of the purpose of the node --> <define name="help"> <element name="help"> |
