@@ -224,86 +224,106 @@ schema_unsupported_test() ->
224
224
-ifndef (erlang_deprecated_types ).
225
225
-ifndef (COMMON_TEST ). % see Emakefile
226
226
map_schema_test () ->
227
- [map_schema_test_draft (URI )
228
- || URI <- [<<" http://json-schema.org/draft-03/schema#" >>,
229
- <<" http://json-schema.org/draft-04/schema#" >>]].
227
+ [ map_schema_test_draft (URI )
228
+ || URI <- [ <<" http://json-schema.org/draft-03/schema#" >>
229
+ , <<" http://json-schema.org/draft-04/schema#" >>
230
+ ]].
230
231
231
232
map_schema_test_draft (URI ) ->
232
- Schema = #{<<" $schema" >> => URI ,
233
- <<" type" >> => <<" object" >>,
234
- <<" properties" >> =>
235
- #{
236
- <<" foo" >> =>
237
- #{<<" type" >> => <<" object" >>,
238
- <<" properties" >> =>
239
- #{<<" subfoo" >> => #{<<" type" >> => <<" integer" >>}}
240
- }
241
- },
242
- <<" patternProperties" >> =>
243
- #{<<" ^b" >> => #{<<" type" >> => <<" integer" >>}}
233
+ Schema = #{ <<" $schema" >> => URI
234
+ , <<" type" >> => <<" object" >>
235
+ , <<" properties" >> =>
236
+ #{ <<" foo" >> =>
237
+ #{ <<" type" >> => <<" object" >>
238
+ , <<" properties" >> =>
239
+ #{ <<" subfoo" >> => #{ <<" type" >> => <<" integer" >>
240
+ }
241
+ }
242
+ }
243
+ }
244
+ , <<" patternProperties" >> =>
245
+ #{ <<" ^b" >> => #{ <<" type" >> => <<" integer" >>
246
+ }
247
+ }
244
248
},
245
- ValidJson = {[ {<<" foo" >>, {[ {<<" subfoo" >>, 42 } ]}},
246
- {<<" bar" >>, 42 },
247
- {<<" baz" >>, 42 }
248
- ]},
249
+ ValidJson = {[ {<<" foo" >>, {[ {<<" subfoo" >>, 42 } ]}}
250
+ , {<<" bar" >>, 42 }
251
+ , {<<" baz" >>, 42 }
252
+ ]},
249
253
? assertEqual ({ok , ValidJson } ,
250
254
jesse_schema_validator :validate (Schema , ValidJson , [])),
251
255
252
256
InvalidJson = {[ {<<" bar" >>, <<" str expect int" >>} ]},
253
- ? assertThrow ([{data_invalid ,
254
- #{<<" type" >> := <<" integer" >>},
255
- wrong_type ,
256
- <<" str expect int" >>,
257
- [<<" bar" >>]}],
257
+ ? assertThrow ([{ data_invalid
258
+ , #{<<" type" >> := <<" integer" >>}
259
+ , wrong_type
260
+ , <<" str expect int" >>
261
+ , [<<" bar" >>]
262
+ }],
258
263
jesse_schema_validator :validate (Schema , InvalidJson , [])).
259
264
260
265
261
266
map_data_test () ->
262
- [map_data_test_draft (URI )
263
- || URI <- [<<" http://json-schema.org/draft-03/schema#" >>,
264
- <<" http://json-schema.org/draft-04/schema#" >>]].
267
+ [ map_data_test_draft (URI )
268
+ || URI <- [ <<" http://json-schema.org/draft-03/schema#" >>
269
+ , <<" http://json-schema.org/draft-04/schema#" >>
270
+ ]
271
+ ].
265
272
266
273
267
274
map_data_test_draft (URI ) ->
268
- Schema = {[ {<<" $schema" >>, URI },
269
- {<<" type" >>, <<" object" >>},
270
- {<<" properties" >>,
271
- {[
272
- {<<" foo" >>,
273
- {[ {<<" type" >>, <<" object" >>},
274
- {<<" properties" >>,
275
- {[ {<<" subfoo" >>, {[ {<<" type" >>, <<" integer" >>} ]}} ]}
276
- }
277
- ]}
278
- }
279
- ]}
280
- },
281
- {<<" patternProperties" >>,
282
- {[ {<<" ^b" >>, {[ {<<" type" >>, <<" integer" >>} ]}} ]}}
275
+ Schema = {[ {<<" $schema" >>, URI }
276
+ , {<<" type" >>, <<" object" >>}
277
+ , {<<" properties" >>
278
+ , {[{ <<" foo" >>
279
+ , {[ {<<" type" >>, <<" object" >>}
280
+ , { <<" properties" >>
281
+ , {[{ <<" subfoo" >>
282
+ , {[{ <<" type" >>
283
+ , <<" integer" >>
284
+ }]}
285
+ }]}
286
+ }
287
+ ]}
288
+ }
289
+ ]}
290
+ }
291
+ , { <<" patternProperties" >>
292
+ , {[{ <<" ^b" >>
293
+ , {[{<<" type" >>, <<" integer" >>}]}
294
+ }]}}
283
295
]},
284
- ValidJson = #{<<" foo" >> => #{<<" subfoo" >> => 42 },
285
- <<" bar" >> => 42 ,
286
- <<" baz" >> => 42
287
- },
288
- ? assertEqual ({ok , ValidJson } ,
289
- jesse_schema_validator :validate (Schema , ValidJson , [])),
296
+ ValidJson = #{ <<" foo" >> => #{<<" subfoo" >> => 42 }
297
+ , <<" bar" >> => 42
298
+ , <<" baz" >> => 42
299
+ },
300
+ ? assertEqual ( {ok , ValidJson }
301
+ , jesse_schema_validator :validate (Schema , ValidJson , [])
302
+ ),
290
303
291
- InvalidJson = #{<<" foo" >> => 42 ,
292
- <<" baz" >> => #{}},
304
+ InvalidJson = #{ <<" foo" >> => 42
305
+ , <<" baz" >> => #{}
306
+ },
293
307
% % XXX: order of errors isn't guaranteed
294
308
% % In case of future fails it can be replaced with manual catching and sorting
295
309
% % of throwed error list, then checked using ?assertMatch
296
- ? assertThrow ([{data_invalid ,
297
- {[ {<<" type" >>, <<" object" >>} | _ ]},
298
- wrong_type , 42 ,
299
- [<<" foo" >>]}
300
- ,{data_invalid ,
301
- {[ {<<" type" >>, <<" integer" >>} ]},
302
- wrong_type , #{},
303
- [<<" baz" >>]}
304
- ],
305
- jesse_schema_validator :validate (Schema , InvalidJson ,
306
- [{allowed_errors , infinity }])).
310
+ ? assertThrow ([ { data_invalid
311
+ , {[{<<" type" >>, <<" object" >>} | _ ]}
312
+ , wrong_type
313
+ , 42
314
+ , [<<" foo" >>]
315
+ }
316
+ , { data_invalid
317
+ , {[{<<" type" >>, <<" integer" >>}]}
318
+ , wrong_type
319
+ , #{}
320
+ , [<<" baz" >>]
321
+ }
322
+ ],
323
+ jesse_schema_validator :validate ( Schema
324
+ , InvalidJson
325
+ , [{allowed_errors , infinity }]
326
+ )).
307
327
308
328
-endif .
309
329
-endif .
0 commit comments