From 01aeeae707199f37804fa6096f836e96fa827818 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 2 Nov 2024 14:58:56 +0100 Subject: [PATCH] [tutorial 083] A variable with custom validation (config and doc) --- README.md | 33 ++++++++++++++++----------------- config/03/output_ro.html | 17 +++++------------ 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 1ebb7f9..f7ab59e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ - [Summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/1.1/README.md) -- [[tutorial 081] A choice variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_081/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_081~1..v1.1_081)) +- [[tutorial 082] A web_address variable ](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_082/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_082~1..v1.1_082)) -# [tutorial 082] A web_address variable +# [tutorial 083] A variable with custom validation -[View the diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_082~1..v1.1_082) +[View the diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_083~1..v1.1_083) ## Screenshot @@ -203,6 +203,12 @@ dns_over_https: # DNS over HTTPS provider is not custom {% endif %} description: if "dns_over_https.provider" is not "Custom" + validators: + - jinja: | + {% if dns_over_https.custom_dns_url.startswith('http://') %} + only https is allowed + {% endif %} + description: must starts with 'https://' only ``` ### Generated documentation @@ -266,7 +272,7 @@ This family builds families dynamically. |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **dns_over_https.enable_dns_over_https**
[`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` | Enable DNS over HTTPS.
**Default**: False | | **dns_over_https.provider**
[`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` _`disabled`_ | Use Provider.
**Choices**:
- Cloudflare ← (default)
- NextDNS
- Custom
**Disabled**: dns_over_https.enable_dns_over_https. | -| **dns_over_https.custom_dns_url**
[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` _`disabled`_ | Custom DNS URL.
**Disabled**: if "dns_over_https.provider" is not "Custom". | +| **dns_over_https.custom_dns_url**
[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` _`disabled`_ | Custom DNS URL.
**Validator**: must starts with 'https://' only.
**Disabled**: if "dns_over_https.provider" is not "Custom". | ## User data @@ -342,18 +348,11 @@ dns_over_https: ```console foo@bar:~$ rougail -v 1.1 -m firefox/ --modes_level basic standard advanced -u file -ff config/03/config.yaml ``` -
╭────────────────────────── Caption ──────────────────────────╮
-│ Variable                           Default value            │
-│ Undocumented variable              Modified value           │
-│ Undocumented but modified variable (Original default value) │
-│ Unmodifiable variable                                       │
-╰─────────────────────────────────────────────────────────────╯
-Variables:
-┣━━ 📓 proxy_mode: No proxy
-┗━━ 📂 dns_over_https
-    ┣━━ 📓 enable_dns_over_https: True
-    ┣━━ 📓 provider: Custom (Cloudflare)
-    ┗━━ 📓 custom_dns_url: http://dns.net
+
🛑 ERRORS
+┣━━ "http://dns.net" is an invalid URL for "dns_over_https.custom_dns_url (Custom DNS URL)", only https 
+is allowed
+┣━━ The following variables are mandatory but have no value:
+┗━━   - dns_over_https.custom_dns_url (Custom DNS URL)
 
### Example 4 @@ -388,4 +387,4 @@ Variables:
-- [[tutorial 083] A variable with custom validation](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_083/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_083~1..v1.1_083)) +- [[tutorial 090] Variable in same family](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_090/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_090~1..v1.1_090)) diff --git a/config/03/output_ro.html b/config/03/output_ro.html index 94673d0..6df626a 100644 --- a/config/03/output_ro.html +++ b/config/03/output_ro.html @@ -1,13 +1,6 @@ -
╭────────────────────────── Caption ──────────────────────────╮
-│ Variable                           Default value            │
-│ Undocumented variable              Modified value           │
-│ Undocumented but modified variable (Original default value) │
-│ Unmodifiable variable                                       │
-╰─────────────────────────────────────────────────────────────╯
-Variables:
-┣━━ 📓 proxy_mode: No proxy
-┗━━ 📂 dns_over_https
-    ┣━━ 📓 enable_dns_over_https: True
-    ┣━━ 📓 provider: Custom (Cloudflare)
-    ┗━━ 📓 custom_dns_url: http://dns.net
+
🛑 ERRORS
+┣━━ "http://dns.net" is an invalid URL for "dns_over_https.custom_dns_url (Custom DNS URL)", only https 
+is allowed
+┣━━ The following variables are mandatory but have no value:
+┗━━   - dns_over_https.custom_dns_url (Custom DNS URL)