domain name

This commit is contained in:
gwen 2025-12-04 20:36:51 +01:00
parent b437572de9
commit 0a10dfbd7d

View file

@ -29,6 +29,24 @@ Some suitable types
We have an `http_proxy` family with an `address` variable in it.
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_022/firefox/10-manual.yml
:language: yaml
:caption: An `address` variable in the `http_proxy` family
..
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_022/firefox/10-manual.yml>`
A variable with type `domainname`
-----------------------------------
We will add a custom type to our `address` variable:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/10-manual.yml
:language: yaml
:caption: An `address` variable in the `http_proxy` family
@ -42,10 +60,7 @@ We have an `http_proxy` family with an `address` variable in it.
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_030/firefox/10-manual.yml>`
A variable with type `domainname`
-----------------------------------
Notice that we have assigned a type to this variable:
Notice that we have assigned the `domainname` type to this variable:
.. code-block:: yaml
:linenos:
@ -180,8 +195,6 @@ we then have this output:
We observe that an error has been raised because an IP address is not a domain name.
Therefore, a type validation is taking place because we declared the type `domainname`.
.. type-along:: A variable with type's parameters
.. questions:: Question
OK I agree with the `domainname` necessary type validation, but what if I want to specify
@ -194,7 +207,8 @@ Well, it is possible to configure the type so that it accepts IP addresses.
We need to specify whether our variable accepts to be filled using an IP or a domain name only.
This is where the ability to parameterize our variable comes in.
.. rubric:: Let's add a type parameter.
A variable with type's parameters
-------------------------------------
.. type-along:: For those who follow the tutorial with the help of the git repository
@ -226,9 +240,9 @@ The params allow the domain name `address` variable to be set with IPs.
.. glossary::
parameter
type parameter
A parameter is a property of a variable that can refine its behavior.
A type parameter is a parameter of a variable that can refine its behavior.
It is declared by adding the `params` attribute in the variable's
definition.
@ -446,6 +460,6 @@ We could of course perform several tests on type validators, but here the valida
.. keypoints:: let's review the key points
- we can assign a `domainname` type to a variable
- we can set a :term:`parameter` to a `domainname` variable to refine their typing behavior
- we can set a :term:`type parameter` to a `domainname` variable to refine their typing behavior
- we can assign a `port` type to a variable
- we know how to set a `boolean` type variable to `true` or `false`