rougail/doc/check/redefine.md

65 lines
1.5 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 :
2022-11-03 22:17:43 +01:00
```yml
2023-10-12 08:17:30 +02:00
---
version: '1.0'
my_variable:
validators:
- type: jinja
jinja: |+
{% if rougail.my_variable and not rougail.my_variable.islower() %}
{{ rougail.my_variable }} is not lowercase string
{% endif %}
2022-11-02 22:52:50 +01:00
```
2021-02-15 15:17:23 +01:00
Dans un second dictionnaire il est possible de redéfinir le calcul :
2022-11-03 22:17:43 +01:00
```yml
2023-10-12 08:17:30 +02:00
---
version: '1.0'
my_variable:
redefine: true
validators:
- type: jinja
jinja: |+
{% if rougail.my_variable and ' ' in rougail.my_variable %}
{{ rougail.my_variable }} has a space
{% endif %}
2022-11-02 22:52:50 +01:00
```
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 :
2022-11-03 22:17:43 +01:00
```yml
2023-10-12 08:17:30 +02:00
---
version: '1.0'
my_variable:
validators:
- type: jinja
jinja: |+
{% if rougail.my_variable and not rougail.my_variable.islower() %}
{{ rougail.my_variable }} is not lowercase string
{% endif %}
2022-11-02 22:52:50 +01:00
```
2021-02-15 15:17:23 +01:00
Dans un second dictionnaire supprimer cette vérification :
2022-11-03 22:17:43 +01:00
```yml
2023-10-12 08:17:30 +02:00
---
version: '1.0'
my_variable:
redefine: true
validators:
2022-11-02 22:52:50 +01:00
```