Skip to content

Commit 22db940

Browse files
committed
use contains for vehicle_events rule
Ensure that the vehicle_events array contains at least one of the valid transition events for the given vehicle_state
1 parent 815fa88 commit 22db940

6 files changed

Lines changed: 84 additions & 618 deletions

File tree

agency/get_vehicle.json

Lines changed: 14 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,10 @@
198198
{
199199
"properties": {
200200
"state": {
201-
"enum": [
202-
"available"
203-
]
201+
"const": "available"
204202
},
205203
"prev_events": {
206-
"items": {
207-
"not": {
208-
"enum": [
209-
"agency_drop_off",
210-
"battery_charged",
211-
"comms_restored",
212-
"maintenance",
213-
"on_hours",
214-
"provider_drop_off",
215-
"reservation_cancel",
216-
"system_resume",
217-
"trip_cancel",
218-
"trip_end",
219-
"unspecified"
220-
]
221-
}
222-
},
223-
"additionalItems": {
204+
"contains": {
224205
"enum": [
225206
"agency_drop_off",
226207
"battery_charged",
@@ -241,20 +222,10 @@
241222
{
242223
"properties": {
243224
"state": {
244-
"enum": [
245-
"elsewhere"
246-
]
225+
"const": "elsewhere"
247226
},
248227
"prev_events": {
249-
"items": {
250-
"not": {
251-
"enum": [
252-
"comms_restored",
253-
"trip_leave_jurisdiction"
254-
]
255-
}
256-
},
257-
"additionalItems": {
228+
"contains": {
258229
"enum": [
259230
"comms_restored",
260231
"trip_leave_jurisdiction"
@@ -266,24 +237,10 @@
266237
{
267238
"properties": {
268239
"state": {
269-
"enum": [
270-
"non_operational"
271-
]
240+
"const": "non_operational"
272241
},
273242
"prev_events": {
274-
"items": {
275-
"not": {
276-
"enum": [
277-
"battery_low",
278-
"comms_restored",
279-
"maintenance",
280-
"off_hours",
281-
"system_suspend",
282-
"unspecified"
283-
]
284-
}
285-
},
286-
"additionalItems": {
243+
"contains": {
287244
"enum": [
288245
"battery_low",
289246
"comms_restored",
@@ -299,21 +256,10 @@
299256
{
300257
"properties": {
301258
"state": {
302-
"enum": [
303-
"on_trip"
304-
]
259+
"const": "on_trip"
305260
},
306261
"prev_events": {
307-
"items": {
308-
"not": {
309-
"enum": [
310-
"comms_restored",
311-
"trip_enter_jurisdiction",
312-
"trip_start"
313-
]
314-
}
315-
},
316-
"additionalItems": {
262+
"contains": {
317263
"enum": [
318264
"comms_restored",
319265
"trip_enter_jurisdiction",
@@ -326,24 +272,10 @@
326272
{
327273
"properties": {
328274
"state": {
329-
"enum": [
330-
"removed"
331-
]
275+
"const": "removed"
332276
},
333277
"prev_events": {
334-
"items": {
335-
"not": {
336-
"enum": [
337-
"agency_pick_up",
338-
"compliance_pick_up",
339-
"decommissioned",
340-
"maintenance_pick_up",
341-
"rebalance_pick_up",
342-
"unspecified"
343-
]
344-
}
345-
},
346-
"additionalItems": {
278+
"contains": {
347279
"enum": [
348280
"agency_pick_up",
349281
"compliance_pick_up",
@@ -359,20 +291,10 @@
359291
{
360292
"properties": {
361293
"state": {
362-
"enum": [
363-
"reserved"
364-
]
294+
"const": "reserved"
365295
},
366296
"prev_events": {
367-
"items": {
368-
"not": {
369-
"enum": [
370-
"comms_restored",
371-
"reservation_start"
372-
]
373-
}
374-
},
375-
"additionalItems": {
297+
"contains": {
376298
"enum": [
377299
"comms_restored",
378300
"reservation_start"
@@ -384,21 +306,10 @@
384306
{
385307
"properties": {
386308
"state": {
387-
"enum": [
388-
"unknown"
389-
]
309+
"const": "unknown"
390310
},
391311
"prev_events": {
392-
"items": {
393-
"not": {
394-
"enum": [
395-
"comms_lost",
396-
"missing",
397-
"unspecified"
398-
]
399-
}
400-
},
401-
"additionalItems": {
312+
"contains": {
402313
"enum": [
403314
"comms_lost",
404315
"missing",

agency/post_vehicle_event.json

Lines changed: 14 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,10 @@
170170
{
171171
"properties": {
172172
"vehicle_state": {
173-
"enum": [
174-
"available"
175-
]
173+
"const": "available"
176174
},
177175
"event_types": {
178-
"items": {
179-
"not": {
180-
"enum": [
181-
"agency_drop_off",
182-
"battery_charged",
183-
"comms_restored",
184-
"maintenance",
185-
"on_hours",
186-
"provider_drop_off",
187-
"reservation_cancel",
188-
"system_resume",
189-
"trip_cancel",
190-
"trip_end",
191-
"unspecified"
192-
]
193-
}
194-
},
195-
"additionalItems": {
176+
"contains": {
196177
"enum": [
197178
"agency_drop_off",
198179
"battery_charged",
@@ -213,20 +194,10 @@
213194
{
214195
"properties": {
215196
"vehicle_state": {
216-
"enum": [
217-
"elsewhere"
218-
]
197+
"const": "elsewhere"
219198
},
220199
"event_types": {
221-
"items": {
222-
"not": {
223-
"enum": [
224-
"comms_restored",
225-
"trip_leave_jurisdiction"
226-
]
227-
}
228-
},
229-
"additionalItems": {
200+
"contains": {
230201
"enum": [
231202
"comms_restored",
232203
"trip_leave_jurisdiction"
@@ -238,24 +209,10 @@
238209
{
239210
"properties": {
240211
"vehicle_state": {
241-
"enum": [
242-
"non_operational"
243-
]
212+
"const": "non_operational"
244213
},
245214
"event_types": {
246-
"items": {
247-
"not": {
248-
"enum": [
249-
"battery_low",
250-
"comms_restored",
251-
"maintenance",
252-
"off_hours",
253-
"system_suspend",
254-
"unspecified"
255-
]
256-
}
257-
},
258-
"additionalItems": {
215+
"contains": {
259216
"enum": [
260217
"battery_low",
261218
"comms_restored",
@@ -271,21 +228,10 @@
271228
{
272229
"properties": {
273230
"vehicle_state": {
274-
"enum": [
275-
"on_trip"
276-
]
231+
"const": "on_trip"
277232
},
278233
"event_types": {
279-
"items": {
280-
"not": {
281-
"enum": [
282-
"comms_restored",
283-
"trip_enter_jurisdiction",
284-
"trip_start"
285-
]
286-
}
287-
},
288-
"additionalItems": {
234+
"contains": {
289235
"enum": [
290236
"comms_restored",
291237
"trip_enter_jurisdiction",
@@ -298,24 +244,10 @@
298244
{
299245
"properties": {
300246
"vehicle_state": {
301-
"enum": [
302-
"removed"
303-
]
247+
"const": "removed"
304248
},
305249
"event_types": {
306-
"items": {
307-
"not": {
308-
"enum": [
309-
"agency_pick_up",
310-
"compliance_pick_up",
311-
"decommissioned",
312-
"maintenance_pick_up",
313-
"rebalance_pick_up",
314-
"unspecified"
315-
]
316-
}
317-
},
318-
"additionalItems": {
250+
"contains": {
319251
"enum": [
320252
"agency_pick_up",
321253
"compliance_pick_up",
@@ -331,20 +263,10 @@
331263
{
332264
"properties": {
333265
"vehicle_state": {
334-
"enum": [
335-
"reserved"
336-
]
266+
"const": "reserved"
337267
},
338268
"event_types": {
339-
"items": {
340-
"not": {
341-
"enum": [
342-
"comms_restored",
343-
"reservation_start"
344-
]
345-
}
346-
},
347-
"additionalItems": {
269+
"contains": {
348270
"enum": [
349271
"comms_restored",
350272
"reservation_start"
@@ -356,21 +278,10 @@
356278
{
357279
"properties": {
358280
"vehicle_state": {
359-
"enum": [
360-
"unknown"
361-
]
281+
"const": "unknown"
362282
},
363283
"event_types": {
364-
"items": {
365-
"not": {
366-
"enum": [
367-
"comms_lost",
368-
"missing",
369-
"unspecified"
370-
]
371-
}
372-
},
373-
"additionalItems": {
284+
"contains": {
374285
"enum": [
375286
"comms_lost",
376287
"missing",

0 commit comments

Comments
 (0)