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: docs/dev/validation.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,6 +161,37 @@ You can also specify additional hints and help messages with an attribute:
161
161
|**_help**| Help displayed when a value does not match the data type.<br>Overrides the built-in help message |
162
162
|**_hint**| Additional hint(s) displayed together with an error message.<br>Use this attribute to explain what could be wrong |
163
163
164
+
(validation-error-type)=
165
+
### Error Data Type
166
+
167
+
Sometimes you want to display a very specific error message when encountering an invalid attribute. For example, the **config.inline** validation test attribute only works when the **[files](plugin-files)** plugin is enabled. You can use the **error** data type to catch such scenarios, for example:
168
+
169
+
```
170
+
_v_entry: # Validation entry
171
+
config:
172
+
inline:
173
+
type: error
174
+
_err_msg: Enable "files" plugin to use the "inline" configuration template
175
+
_alt_types: [ str ]
176
+
```
177
+
178
+
You can also use the **error** data type as a **_subtype** definition when an attribute can have a dictionary value only under very specific conditions. For example, the node **config** attribute is usually a list but could be a dictionary if the lab topology uses the **files** plugin:
179
+
180
+
```
181
+
node:
182
+
config:
183
+
type: dict
184
+
_subtype:
185
+
type: error
186
+
_err_msg: Enable "files" plugin to use the inline node/group configuration template(s)
187
+
_alt_types: [ list ]
188
+
```
189
+
190
+
The **error** data type can have two additional attributes:
191
+
192
+
***_err_msg**: The text to display as a hint to the user
193
+
***_err_hint**: A hint from the **defaults.hints** dictionary to display as an explanation of the error
0 commit comments