aboutsummaryrefslogtreecommitdiff
path: root/lang/python/python-jsonschema/test.sh
blob: 37fe4925a9056f378066e258d69024e81bd11f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

[ "$1" = python3-jsonschema ] || exit 0

python3 - << 'EOF'

from jsonschema import validate

# A sample schema, like what we'd get from json.load()
schema = {
    "type" : "object",
    "properties" : {
        "price" : {"type" : "number"},
        "name" : {"type" : "string"},
    },
}

# If no exception is raised by validate(), the instance is valid.
validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema)

EOF