summaryrefslogtreecommitdiff
path: root/tests/draft-future/optional/format/duration.json
blob: 741348ae758ca4b0e4bc36da6a5746bf3c916b09 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
[
    {
        "description": "validation of duration strings",
        "schema": { "format": "duration" },
        "tests": [
            {
                "description": "all string formats ignore integers",
                "data": 12,
                "valid": true
            },
            {
                "description": "all string formats ignore floats",
                "data": 13.7,
                "valid": true
            },
            {
                "description": "all string formats ignore objects",
                "data": {},
                "valid": true
            },
            {
                "description": "all string formats ignore arrays",
                "data": [],
                "valid": true
            },
            {
                "description": "all string formats ignore booleans",
                "data": false,
                "valid": true
            },
            {
                "description": "all string formats ignore nulls",
                "data": null,
                "valid": true
            },
            {
                "description": "a valid duration string",
                "data": "P4DT12H30M5S",
                "valid": true
            },
            {
                "description": "an invalid duration string",
                "data": "PT1D",
                "valid": false
            },
            {
                "description": "no elements present",
                "data": "P",
                "valid": false
            },
            {
                "description": "no time elements present",
                "data": "P1YT",
                "valid": false
            },
            {
                "description": "no date or time elements present",
                "data": "PT",
                "valid": false
            },
            {
                "description": "elements out of order",
                "data": "P2D1Y",
                "valid": false
            },
            {
                "description": "missing time separator",
                "data": "P1D2H",
                "valid": false
            },
            {
                "description": "time element in the date position",
                "data": "P2S",
                "valid": false
            },
            {
                "description": "four years duration",
                "data": "P4Y",
                "valid": true
            },
            {
                "description": "zero time, in seconds",
                "data": "PT0S",
                "valid": true
            },
            {
                "description": "zero time, in days",
                "data": "P0D",
                "valid": true
            },
            {
                "description": "one month duration",
                "data": "P1M",
                "valid": true
            },
            {
                "description": "one minute duration",
                "data": "PT1M",
                "valid": true
            },
            {
                "description": "one and a half days, in hours",
                "data": "PT36H",
                "valid": true
            },
            {
                "description": "one and a half days, in days and hours",
                "data": "P1DT12H",
                "valid": true
            },
            {
                "description": "two weeks",
                "data": "P2W",
                "valid": true
            },
            {
                "description": "weeks cannot be combined with other units",
                "data": "P1Y2W",
                "valid": false
            },
            {
                "description": "non-ascii digits should be rejected",
                "data": "P২Y",
                "valid": false
            }
        ]
    }
]