rougail/doc/check/redefine.md

109 lines
1.8 KiB
Markdown
Raw Normal View History

2021-02-15 15:17:23 +01:00
# Rédéfinition
## Redéfinition des vérification
Dans un premier dictionnaire déclarons notre variable et sa fonction de vérification :
```
<variables>
2021-12-11 16:33:55 +01:00
<variable name="my_variable"/>
2021-02-15 15:17:23 +01:00
</variables>
<constraints>
2021-12-11 16:33:55 +01:00
<check name="islower">
<target>my_variable</target>
</check>
2021-02-15 15:17:23 +01:00
</constraints>
```
2022-11-02 22:52:50 +01:00
En YAML :
```
variables:
- variable:
name: my_variable
constraints:
- check:
- name: islower
target:
- text: my_variable
```
2021-02-15 15:17:23 +01:00
Dans un second dictionnaire il est possible de redéfinir le calcul :
```
<variables>
2021-12-11 16:33:55 +01:00
<variable name="my_variable" redefine="True"/>
2021-02-15 15:17:23 +01:00
</variables>
<constraints>
2021-12-11 16:33:55 +01:00
<check name="isspace">
<target>my_variable</target>
</check>
2021-02-15 15:17:23 +01:00
</constraints>
```
2022-11-02 22:52:50 +01:00
En YAML :
```
variables:
- variable:
name: my_variable
redefine: 'True'
constraints:
- check:
- name: isspace
target:
- text: my_variable
```
2021-02-15 15:17:23 +01:00
Dans ce cas, la fonction "islower" exécuté. Si cette fonction ne retourne pas d'erreur, la seconde fonction "isspace" sera exécuté.
## Redéfinition avec suppression d'un calcul
Il se peut que dans un dictionnaire on décide de vérifier la valeur d'une variable.
Dans un second dictionnaire il est possible de supprimer cette vérification.
Dans un premier dictionnaire déclarons notre variable et notre fonction de vérification :
```
<variables>
2021-12-11 16:33:55 +01:00
<variable name="my_variable"/>
2021-02-15 15:17:23 +01:00
</variables>
<constraints>
2021-12-11 16:33:55 +01:00
<check name="islower">
<target>my_variable</target>
</check>
2021-02-15 15:17:23 +01:00
</constraints>
```
2022-11-02 22:52:50 +01:00
En YAML :
```
variables:
- variable:
name: my_variable
constraints:
- check:
- name: islower
target:
- text: my_variable
```
2021-02-15 15:17:23 +01:00
Dans un second dictionnaire supprimer cette vérification :
```
<variables>
2022-11-02 22:52:50 +01:00
<variable name="my_variable" redefine="True" remove_check="True"/>
2021-02-15 15:17:23 +01:00
</variables>
```
2022-11-02 22:52:50 +01:00
En YAML :
```
variables:
- variable:
name: my_variable
redefine: 'True'
remove_check: 'True'
```