Naposledy aktivní 1741686418

paramah's Avatar paramah revidoval tento gist 1741686417. Přejít na revizi

1 file changed, 32 insertions

gistfile1.txt(vytvořil soubor)

@@ -0,0 +1,32 @@
1 + package conftest
2 +
3 + import json
4 +
5 + # Funkcja do sprawdzania struktury JSON
6 + is_valid_json(input) {
7 + # Sprawdź, czy input jest łańcuchem znaków
8 + is_string(input)
9 +
10 + # Parsuj JSON
11 + json.parse(input) != null
12 + }
13 +
14 + # Funkcja do sprawdzania struktury connectionstring
15 + is_valid_connection_string(input) {
16 + # Sprawdź, czy input jest łańcuchem znaków
17 + is_string(input)
18 +
19 + # Parsuj JSON
20 + json_data := json.parse(input)
21 +
22 + # Sprawdź, czy JSON zawiera określone pola
23 + json_data["required_field1"] != null
24 + json_data["required_field2"] != null
25 + }
26 +
27 + # Reguła walidacji
28 + deny[msg] {
29 + input.connectionstring != null
30 + not is_valid_connection_string(input.connectionstring)
31 + msg := "Invalid connection string JSON structure"
32 + }
Novější Starší