summaryrefslogtreecommitdiff
path: root/tests/draft3/default.json
blob: 289a9b66c13d5c19f907098e549ccb4081ebdc5e (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
[
    {
        "description": "invalid type for default",
        "schema": {
            "properties": {
                "foo": {
                    "type": "integer",
                    "default": []
                }
            }
        },
        "tests": [
            {
                "description": "valid when property is specified",
                "data": {"foo": 13},
                "valid": true
            },
            {
                "description": "still valid when the invalid default is used",
                "data": {},
                "valid": true
            }
        ]
    },
    {
        "description": "invalid string value for default",
        "schema": {
            "properties": {
                "bar": {
                    "type": "string",
                    "minLength": 4,
                    "default": "bad"
                }
            }
        },
        "tests": [
            {
                "description": "valid when property is specified",
                "data": {"bar": "good"},
                "valid": true
            },
            {
                "description": "still valid when the invalid default is used",
                "data": {},
                "valid": true
            }
        ]
    },
    {
        "description": "the default keyword does not do anything if the property is missing",
        "schema": {
            "type": "object",
            "properties": {
                "alpha": {
                    "type": "number",
                    "maximum": 3,
                    "default": 5
                }
            }
        },
        "tests": [
            {
                "description": "an explicit property value is checked against maximum (passing)",
                "data": { "alpha": 1 },
                "valid": true
            },
            {
                "description": "an explicit property value is checked against maximum (failing)",
                "data": { "alpha": 5 },
                "valid": false
            },
            {
                "description": "missing properties are not filled in with the default",
                "data": {},
                "valid": true
            }
        ]
    }
]