[tutorial v1.1_150] A variable with custom validation (config and doc)

This commit is contained in:
egarette@silique.fr 2026-03-12 08:11:06 +01:00
parent b3dedc7e1d
commit 87c48328c4
3 changed files with 58 additions and 68 deletions

View file

@ -1,9 +1,9 @@
- [Summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/1.1/README.md) - [Summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/1.1/README.md)
- [[tutorial v1.1_141] A choice variable](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_141/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_142~1..v1.1_142)) - [[tutorial v1.1_142] A web_address variable ](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_150~1..v1.1_150))
# [tutorial v1.1_142] A web_address variable # [tutorial v1.1_150] A variable with custom validation
[Read the tutorial "A web_address variable " in the documentation](https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/jinja.html#a-web_address-variable) [Read the tutorial "A variable with custom validation" in the documentation](https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/jinja.html#a-variable-with-custom-validation)
## Screenshot ## Screenshot
@ -29,7 +29,7 @@ pip install rougail-cli rougail-output-exporter rougail-output-doc rougail-user-
Then switch to the tutorial page: Then switch to the tutorial page:
```shell ```shell
git switch --detach v1.1_142 git switch --detach v1.1_150
``` ```
## Structure ## Structure
@ -37,19 +37,19 @@ git switch --detach v1.1_142
<p> <p>
<a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./">.</a><br/> <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./">.</a><br/>
├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/">firefox</a><br/> ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/">firefox</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/00-proxy.yml">00-proxy.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/00-proxy.yml">00-proxy.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/10-manual.yml">10-manual.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/10-manual.yml">10-manual.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/20-manual.yml">20-manual.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/20-manual.yml">20-manual.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/30-auto.yml">30-auto.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/30-auto.yml">30-auto.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/40-no_proxy.yml">40-no_proxy.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/40-no_proxy.yml">40-no_proxy.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/50-prompt_authentication.yml">50-prompt_authentication.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/50-prompt_authentication.yml">50-prompt_authentication.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/55-proxy_dns_socks5.yml">55-proxy_dns_socks5.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/55-proxy_dns_socks5.yml">55-proxy_dns_socks5.yml</a><br/>
│   └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/60-dns_over_https.yml">60-dns_over_https.yml</a><br/> │   └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/60-dns_over_https.yml">60-dns_over_https.yml</a><br/>
└── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/">types</a><br/> └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/">types</a><br/>
    └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/proxy/">proxy</a><br/>     └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/proxy/">proxy</a><br/>
        └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/proxy/00_type.yml">00_type.yml</a><br/>         └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/proxy/00_type.yml">00_type.yml</a><br/>
<br/><br/></p> <br/><br/></p>
Contents of the firefox/60-dns_over_https.yml file Contents of the firefox/60-dns_over_https.yml file
@ -77,6 +77,11 @@ dns_over_https: # DNS over HTTPS
custom_dns_url: custom_dns_url:
description: Custom DNS URL description: Custom DNS URL
type: web_address type: web_address
validators:
- jinja: |-
{{ _.custom_dns_url.startswith("http://") }}
return_type: boolean
description: must starts with 'https://' only
disabled: disabled:
jinja: |- jinja: |-
{{ _.provider is propertyerror or _.provider != 'Custom' }} {{ _.provider is propertyerror or _.provider != 'Custom' }}
@ -161,10 +166,10 @@ rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -o
> `basic` > `basic`
| Variable | Description | | Variable | Description |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="dns_over_https.enable_dns_over_https" name="dns_over_https.enable_dns_over_https">dns_over_https.enable_dns_over_https</a>**<br/>[`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` | Enable DNS over HTTPS.<br/>**Default**: false | | **<a id="dns_over_https.enable_dns_over_https" name="dns_over_https.enable_dns_over_https">dns_over_https.enable_dns_over_https</a>**<br/>[`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` | Enable DNS over HTTPS.<br/>**Default**: false |
| **<a id="dns_over_https.provider" name="dns_over_https.provider">dns_over_https.provider</a>**<br/>[`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` *`disabled`* | Use Provider.<br/>**Choices**: <br/>&nbsp;Cloudflare **← (default)**<br/>&nbsp;NextDNS<br/>&nbsp;Custom<br/>**Disabled**: when the variable "[Enable DNS over HTTPS](#dns_over_https.enable_dns_over_https)" has the value "false" | | **<a id="dns_over_https.provider" name="dns_over_https.provider">dns_over_https.provider</a>**<br/>[`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` *`disabled`* | Use Provider.<br/>**Choices**: <br/>&nbsp;Cloudflare **← (default)**<br/>&nbsp;NextDNS<br/>&nbsp;Custom<br/>**Disabled**: when the variable "[Enable DNS over HTTPS](#dns_over_https.enable_dns_over_https)" has the value "false" |
| **<a id="dns_over_https.custom_dns_url" name="dns_over_https.custom_dns_url">dns_over_https.custom_dns_url</a>**<br/>[`web address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>&nbsp;well-known ports (1 to 1023) are allowed<br/>&nbsp;registred ports (1024 to 49151) are allowed<br/>&nbsp;type domainname<br/>&nbsp;the domain name can be a hostname<br/>**Disabled**: if "[Use Provider](#dns_over_https.provider)" is not "Custom" | | **<a id="dns_over_https.custom_dns_url" name="dns_over_https.custom_dns_url">dns_over_https.custom_dns_url</a>**<br/>[`web address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>&nbsp;well-known ports (1 to 1023) are allowed<br/>&nbsp;registred ports (1024 to 49151) are allowed<br/>&nbsp;type domainname<br/>&nbsp;the domain name can be a hostname<br/>&nbsp;must starts with 'https://' only<br/>**Disabled**: if "[Use Provider](#dns_over_https.provider)" is not "Custom" |
*** ***
@ -173,11 +178,11 @@ rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -o
```shell ```shell
rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -o doc --doc.contents changelog --doc.changelog.previous_json_file previous.yml rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -o doc --doc.contents changelog --doc.changelog.previous_json_file previous.yml
``` ```
#### New variable #### Modified variable
| Variable | Description | | Variable | Description |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="dns_over_https.custom_dns_url" name="dns_over_https.custom_dns_url">dns_over_https.custom_dns_url</a>**<br/>[`web address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>&nbsp;well-known ports (1 to 1023) are allowed<br/>&nbsp;registred ports (1024 to 49151) are allowed<br/>&nbsp;type domainname<br/>&nbsp;the domain name can be a hostname<br/>**Disabled**: if "[Use Provider](#dns_over_https.provider)" is not "Custom" | | **<a id="dns_over_https.custom_dns_url" name="dns_over_https.custom_dns_url">dns_over_https.custom_dns_url</a>**<br/>[`web address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>&nbsp;well-known ports (1 to 1023) are allowed<br/>&nbsp;registred ports (1024 to 49151) are allowed<br/>&nbsp;type domainname<br/>&nbsp;the domain name can be a hostname<br/>&nbsp;<ins>must starts with 'https://' only</ins><br/>**Disabled**: if "[Use Provider](#dns_over_https.provider)" is not "Custom" |
*** ***
@ -261,20 +266,12 @@ dns_over_https:
```shell ```shell
rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -u yaml -yf config/03/config.yml rougail -m firefox/ --types types/proxy --modes_level basic standard advanced -u yaml -yf config/03/config.yml
``` ```
> [!NOTE] > [!CAUTION]
> >
> **Caption:** > - dns_over_https (DNS over HTTPS)
> - Variable > - custom_dns_url (Custom DNS URL)
> - <span style="color: #B8860B">Default value</span> > - <span style='color: #EFBF04'>:bell: the value "http://dns.net" is an invalid URL, must starts with 'https://' only, it will be ignored when loading from the YAML file "config/03/config.yml"</span>
> - <span style="color: #006400">Modified value</span> > - <span style='color: #C23636'>:stop_sign: mandatory variable but has no value</span>
> - (:hourglass_flowing_sand: Original default value)
Variables:
- :notebook: proxy_mode (Configure Proxy Access to the Internet): <span style="color: #B8860B">No proxy</span>
- :open_file_folder: dns_over_https (DNS over HTTPS)
- :notebook: enable_dns_over_https (Enable DNS over HTTPS): <span style="color: #006400">true</span> ← loaded from the YAML file "config/03/config.yml" (:hourglass_flowing_sand: false)
- :notebook: provider (Use Provider): <span style="color: #006400">Custom</span> ← loaded from the YAML file "config/03/config.yml" (:hourglass_flowing_sand: Cloudflare)
- :notebook: custom_dns_url (Custom DNS URL): <span style="color: #006400">http://dns.net</span> ← loaded from the YAML file "config/03/config.yml"
*** ***
### Example 4 ### Example 4
@ -314,4 +311,4 @@ Variables:
*** ***
- [[tutorial v1.1_150] A variable with custom validation](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_150~1..v1.1_150)) - [[tutorial v1.1_160] Namespace](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_160/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_160~1..v1.1_160))

View file

@ -1,15 +1,8 @@
<pre>╭────────────── Caption ───────────────╮ <pre><span style="font-weight: bold; color: #ff0000">🛑 Caution</span>
│ Variable <span style="color: #ffd700">Default value</span> <span style="color: #ff0000">┗━━ </span>dns_over_https (DNS over HTTPS)
<span style="color: #00aa00">Modified value</span> <span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span>custom_dns_url (Custom DNS URL)
│ (⏳ Original default value) │ <span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000">┣━━ </span><span style="color: #ffff00">🔔 the value "http://dns.net" is an invalid URL, must starts with </span>
╰──────────────────────────────────────╯ <span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000"></span><span style="color: #ffff00">'https://' only, it will be ignored when loading from the YAML file </span>
Variables: <span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000"></span><span style="color: #ffff00">"config/03/config.yml"</span>
<span style="color: #5c5cff">┣━━ </span>📓 proxy_mode (Configure Proxy Access to the Internet): <span style="color: #ffd700">No proxy</span> <span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span><span style="color: #ff0000">🛑 mandatory variable but has no value</span>
<span style="color: #5c5cff">┗━━ </span>📂 dns_over_https (DNS over HTTPS)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 enable_dns_over_https (Enable DNS over HTTPS): <span style="color: #00aa00">true</span> ◀ loaded from the
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"></span>YAML file "config/03/config.yml" (⏳ false)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 provider (Use Provider): <span style="color: #00aa00">Custom</span> ◀ loaded from the YAML file
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"></span>"config/03/config.yml" (⏳ Cloudflare)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📓 custom_dns_url (Custom DNS URL): <span style="color: #00aa00">http://dns.net</span> ◀ loaded from the
<span style="color: #5c5cff"> </span><span style="color: #5c5cff"> </span>YAML file "config/03/config.yml"
</pre> </pre>

View file

@ -1,15 +1,15 @@
<p> <p>
<a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./">.</a><br/> <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./">.</a><br/>
├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/">firefox</a><br/> ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/">firefox</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/00-proxy.yml">00-proxy.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/00-proxy.yml">00-proxy.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/10-manual.yml">10-manual.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/10-manual.yml">10-manual.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/20-manual.yml">20-manual.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/20-manual.yml">20-manual.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/30-auto.yml">30-auto.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/30-auto.yml">30-auto.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/40-no_proxy.yml">40-no_proxy.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/40-no_proxy.yml">40-no_proxy.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/50-prompt_authentication.yml">50-prompt_authentication.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/50-prompt_authentication.yml">50-prompt_authentication.yml</a><br/>
│   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/55-proxy_dns_socks5.yml">55-proxy_dns_socks5.yml</a><br/> │   ├── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/55-proxy_dns_socks5.yml">55-proxy_dns_socks5.yml</a><br/>
│   └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./firefox/60-dns_over_https.yml">60-dns_over_https.yml</a><br/> │   └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./firefox/60-dns_over_https.yml">60-dns_over_https.yml</a><br/>
└── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/">types</a><br/> └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/">types</a><br/>
    └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/proxy/">proxy</a><br/>     └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/proxy/">proxy</a><br/>
        └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_142/./types/proxy/00_type.yml">00_type.yml</a><br/>         └── <a href="https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_150/./types/proxy/00_type.yml">00_type.yml</a><br/>
<br/><br/></p> <br/><br/></p>