-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathtoml_schema.txtar
More file actions
45 lines (40 loc) · 974 Bytes
/
toml_schema.txtar
File metadata and controls
45 lines (40 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# TOML with $schema validates against local schema
exec validator valid.toml
stdout '✓'
# TOML with invalid data fails schema validation
! exec validator invalid.toml
stdout '×'
stdout 'error:'
# TOML without $schema passes (syntax only)
exec validator plain.toml
stdout '✓'
# TOML without $schema + --require-schema fails
! exec validator --require-schema plain.toml
stdout '×'
stdout 'no schema declared'
# TOML with $schema + --require-schema passes
exec validator --require-schema valid.toml
stdout '✓'
-- schema.json --
{
"type": "object",
"required": ["host", "port"],
"properties": {
"host": { "type": "string" },
"port": { "type": "integer" },
"debug": { "type": "boolean" }
},
"additionalProperties": false
}
-- valid.toml --
"$schema" = "schema.json"
host = "localhost"
port = 5432
debug = true
-- invalid.toml --
"$schema" = "schema.json"
host = "localhost"
port = "not_a_number"
-- plain.toml --
host = "localhost"
port = 5432