You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,11 @@ With the Box settings used in the topology data structure:
92
92
* The interim dictionaries are created automatically: `a.b.c=1` works even when `a.b` does not exist yet.
93
93
* The dotted paths can be used in indices (for example, `a['b.c'] = 1`) and in **in** tests (for example `'b.c' in a`)
94
94
95
+
IMPORTANT -- the Box objects must have the default_box and box_dots flags set to work as expected:
96
+
97
+
* When creating a new Box object from a dictionary, use data.get_box function
98
+
* When creating an empty Box object, use data.get_empty_box function
99
+
95
100
### Using Jinja2 templates
96
101
97
102
* The Jinja2 environment uses a custom `undefined` method that can handle dictionary hierarchy. For example, `a.b.c is defined` returns False instead of crashing even when `a.b` does not exist. There is no need for an extra `a.b is defined` guard.
Copy file name to clipboardExpand all lines: docs/dev/validation.md
+2-12Lines changed: 2 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ The dictionary-based approach allows in-depth validation of nested attributes, w
83
83
(dev-valid-data-types)=
84
84
## Valid Data Types
85
85
86
-
Validator recognizes standard Python data types (**str**, **int**, **float**, **bool**, **list** or **dict**) and the following networking-specific data types:
86
+
Validator recognizes standard Python data types (**str**, **int**, **float**, **bool**, **list** or **dict**), the following networking-specific data types, and [user-defined data types](validate-user-types).
87
87
88
88
| Data type. | Meaning |
89
89
|----------------|---------|
@@ -104,7 +104,7 @@ Validator recognizes standard Python data types (**str**, **int**, **float**, **
104
104
|**r_proto**| Routing protocol identifier |
105
105
|**time**| Time duration specified in seconds (`s`) or milliseconds (`ms`) |
106
106
107
-
The data type can be specified as a string (without additional parameters) or a dictionary with a **type** attribute (data type as a string) and other type-specific validation parameters.
107
+
The data type can be specified as a string (without additional parameters) or a dictionary with a **type** attribute (data type as a string) and other type-specific validation parameters. When specifying a user-defined data type with the **type** attribute, the definition of the user-defined data type is *merged* with the type definition.
108
108
109
109
For example, VLAN link parameters include **access** and **native**, which can be any string value, as well as **mode** that must have one of the predefined values:
110
110
@@ -412,16 +412,6 @@ bgp:
412
412
timers: exbs_timers
413
413
```
414
414
415
-
Please note that the following definition (using `exbs_timers` as the value of `timers`**type** attribute) would not work:
416
-
417
-
```
418
-
bgp:
419
-
attributes:
420
-
global:
421
-
timers:
422
-
type: exbs_timers ### INVALID, WON'T WORK
423
-
```
424
-
425
415
You can use the `_namespace` attribute within the user-defined data types to add attributes from other objects. For example, as you can use link attributes in VLAN definitions, the **vlan** definition (see `modules/vlan.yml`) includes the `_namespace` attribute:
0 commit comments