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

This commit is contained in:
egarette@silique.fr 2025-11-07 06:37:47 +01:00
parent d7846ab425
commit 51741a02ea
2 changed files with 31 additions and 35 deletions

View file

@ -1,9 +1,9 @@
- [Summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/1.1/README.md)
- [[tutorial v1.1_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 v1.1_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 v1.1_082)] A web_address variable
# [tutorial v1.1_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
@ -227,6 +227,12 @@ dns_over_https: # DNS over HTTPS
custom_dns_url:
description: Custom DNS URL
type: web_address
validators:
- jinja: |-
{% if dns_over_https.custom_dns_url.startswith('http://') %}
only https is allowed
{% endif %}
description: must starts with 'https://' only
disabled:
jinja: |-
{% if _.provider is propertyerror or _.provider != 'Custom' %}
@ -239,7 +245,7 @@ dns_over_https: # DNS over HTTPS
### Let's generate the documentation
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -o doc
```
| Variable                                                                                                   | Description                                                                                                |
@ -305,19 +311,19 @@ or "firefox.manual.socks_proxy.version" is "v4"
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **dns_over_https.enable_dns_over_https**<br/>[`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` | Enable DNS over HTTPS.<br/>**Default**: false |
| **dns_over_https.provider**<br/>[`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` *`disabled`* | Use Provider.<br/>**Choices**: <br/>- Cloudflare **← (default)**<br/>- NextDNS<br/>- Custom<br/>**Disabled**: when the variable "dns_over_https.enable_dns_over_https" has the value "false" |
| **dns_over_https.custom_dns_url**<br/>[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validator**: the domain name in web address can be only a hostname<br/>**Disabled**: if "_.provider" is not "Custom" |
| **dns_over_https.custom_dns_url**<br/>[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>- the domain name in web address can be only a hostname<br/>- must starts with 'https://' only<br/>**Disabled**: if "_.provider" is not "Custom" |
### Let's generate the changelog
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -o doc --doc.contents changelog
```
#### New variable
#### Modified variable
| Variable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **dns_over_https.custom_dns_url**<br/>[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validator**: the domain name in web address can be only a hostname<br/>**Disabled**: if "_.provider" is not "Custom" |
| **dns_over_https.custom_dns_url**<br/>[`web_address`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` *`disabled`* | Custom DNS URL.<br/>**Validators**: <br/>- the domain name in web address can be only a hostname<br/>- <ins>must starts with 'https://' only</ins><br/>**Disabled**: if "_.provider" is not "Custom" |
## User datas
@ -334,7 +340,7 @@ foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -o doc --do
#### Output
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -u yaml -ff config/01/config.yaml
```
<pre>╭─────── Caption ────────╮
@ -359,7 +365,7 @@ dns_over_https:
#### Output
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -u yaml -ff config/02/config.yaml
```
<pre>╭────────────── Caption ───────────────╮
@ -389,20 +395,15 @@ dns_over_https:
#### Output
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -u yaml -ff config/03/config.yaml
```
<pre>╭────────────── Caption ───────────────╮
│ Variable <span style="color: #ffd700">Default value</span>
│ Modified value │
│ (<span style="color: #00aa00">⏳ Original default value</span>) │
╰──────────────────────────────────────╯
Variables:
<span style="color: #5c5cff">┣━━ </span>📓 Configure Proxy Access to the Internet: <span style="color: #ffd700">No proxy</span>
<span style="color: #5c5cff">┗━━ </span>📂 DNS over HTTPS
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 Enable DNS over HTTPS: true ◀ loaded from the YAML file "config/03/config.yaml" (⏳ <span style="color: #00aa00">false</span>)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 Use Provider: Custom ◀ loaded from the YAML file "config/03/config.yaml" (⏳ <span style="color: #00aa00">Cloudflare</span>)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📓 Custom DNS URL: http://dns.net ◀ loaded from the YAML file "config/03/config.yaml"
<pre><span style="font-weight: bold; color: #ffff00">🔔 WARNINGS</span>
<span style="color: #ffff00">┗━━ </span>the value "http://dns.net" is an invalid URL for "dns_over_https.custom_dns_url" (Custom DNS URL), only https is allowed, it will be ignored when loading from the YAML file "config/03/config.yaml"
<span style="font-weight: bold; color: #ff0000">🛑 ERRORS</span>
<span style="color: #ff0000">┗━━ </span>The following variables are mandatory but have no value:
<span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span>DNS over HTTPS
<span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span>Custom DNS URL
</pre>
### Example 4
@ -420,7 +421,7 @@ dns_over_https:
#### Output
```console
foo@bar:~$ git switch --detach v1.1_082
foo@bar:~$ git switch --detach v1.1_083
foo@bar:~$ rougail -m firefox/ --modes_level basic standard advanced -u yaml -ff config/04/config.yaml
```
<pre>╭────────────── Caption ───────────────╮
@ -437,4 +438,4 @@ Variables:
</pre>
- [[tutorial v1.1_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 v1.1_100] Namespace](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/v1.1_100/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_100~1..v1.1_100))

View file

@ -1,12 +1,7 @@
<pre>╭────────────── Caption ───────────────╮
│ Variable <span style="color: #ffd700">Default value</span>
│ Modified value │
│ (<span style="color: #00aa00">⏳ Original default value</span>) │
╰──────────────────────────────────────╯
Variables:
<span style="color: #5c5cff">┣━━ </span>📓 Configure Proxy Access to the Internet: <span style="color: #ffd700">No proxy</span>
<span style="color: #5c5cff">┗━━ </span>📂 DNS over HTTPS
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 Enable DNS over HTTPS: true ◀ loaded from the YAML file "config/03/config.yaml" (⏳ <span style="color: #00aa00">false</span>)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┣━━ </span>📓 Use Provider: Custom ◀ loaded from the YAML file "config/03/config.yaml" (⏳ <span style="color: #00aa00">Cloudflare</span>)
<span style="color: #5c5cff"> </span><span style="color: #5c5cff">┗━━ </span>📓 Custom DNS URL: http://dns.net ◀ loaded from the YAML file "config/03/config.yaml"
<pre><span style="font-weight: bold; color: #ffff00">🔔 WARNINGS</span>
<span style="color: #ffff00">┗━━ </span>the value "http://dns.net" is an invalid URL for "dns_over_https.custom_dns_url" (Custom DNS URL), only https is allowed, it will be ignored when loading from the YAML file "config/03/config.yaml"
<span style="font-weight: bold; color: #ff0000">🛑 ERRORS</span>
<span style="color: #ff0000">┗━━ </span>The following variables are mandatory but have no value:
<span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span>DNS over HTTPS
<span style="color: #ff0000"> </span><span style="color: #ff0000"> </span><span style="color: #ff0000">┗━━ </span>Custom DNS URL
</pre>